From 9804d86786189251982825ea536f55658aaa3a0e Mon Sep 17 00:00:00 2001 From: zPlus Date: Fri, 5 Aug 2022 07:23:23 +0200 Subject: [PATCH] Fix Log diffstats when commit has no parents. Do not display diffstats in the Log page for commit with no parents (first commit). --- templates/repository/log.html | 8 ++++++-- web.py | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/templates/repository/log.html b/templates/repository/log.html index 696fe32..2ddb8f8 100644 --- a/templates/repository/log.html +++ b/templates/repository/log.html @@ -72,10 +72,14 @@ {{ commit_time(commit.commit_time, commit.commit_time_offset)|ago }} - {{ diff[commit.short_id].stats.files_changed }} + {% if commit.short_id in diff %} + {{ diff[commit.short_id].stats.files_changed }} + {% endif %} - -{{ diff[commit.short_id].stats.deletions }}/+{{ diff[commit.short_id].stats.insertions }} + {% if commit.short_id in diff %} + -{{ diff[commit.short_id].stats.deletions }}/+{{ diff[commit.short_id].stats.insertions }} + {% endif %} {% endfor %} diff --git a/web.py b/web.py index b1331f9..4386480 100644 --- a/web.py +++ b/web.py @@ -505,7 +505,9 @@ def log(repository, revision): break commits.append(commit) - diff[commit.short_id] = commit.parents[0].tree.diff_to_tree(commit.tree) + + if len(commit.parents) > 0: + diff[commit.short_id] = commit.parents[0].tree.diff_to_tree(commit.tree) return template( 'repository/log.html',