diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Show the root commit in a followed log
A followed log diffs each commit against its parent to learn whether the file changed there, and a root commit was skipped rather than diffed against the empty tree, so a file created in the first commit never showed that commit.
Diffstat (limited to '')
-rw-r--r--source/ui-log.c25
1 file changed, 12 insertions, 13 deletions
diff --git a/source/ui-log.c b/source/ui-log.c
index f96689e..8adc5ac 100644
--- a/source/ui-log.c
+++ b/source/ui-log.c
@@ -88,15 +88,16 @@ static void follow_path(struct diff_filepair *pair)
/*
* Whether a commit belongs in the listing. When a single path is being
- * followed the commit is diffed against its one parent here, and the counts
- * that fall out of that diff are kept so the row does not repeat the work.
+ * followed the commit is diffed against its one parent here, or against the
+ * empty tree when it is the root, and the counts that fall out of that diff
+ * are kept so the row does not repeat the work.
*/
static int should_show(struct commit *commit, struct rev_info *revs)
{
// Static, because the walk keeps the address in its diff options.
static filepair_fn follow = follow_path;
struct commit_list *parents = commit->parents;
- struct commit *parent;
+ const struct object_id *parent_tree = NULL;
int found = 0, saved_fmt;
struct diff_flags saved_flags = revs->diffopt.flags;
@@ -108,22 +109,20 @@ static int should_show(struct commit *commit, struct rev_info *revs)
if (parents && parents->next)
return 0;
- if (!parents)
- return revs->show_root_diff;
-
- parent = parents->item;
-
- // A parent that does not parse is left for print_commit to report on,
- // so the commit is shown.
- if (repo_parse_commit(the_repository, parent))
- return 1;
+ if (parents) {
+ // A parent that does not parse is left for print_commit to
+ // report on, so the commit is shown.
+ if (repo_parse_commit(the_repository, parents->item))
+ return 1;
+ parent_tree = get_commit_tree_oid(parents->item);
+ }
file_count = 0;
added_lines = 0;
removed_lines = 0;
revs->diffopt.flags.recursive = 1;
- diff_tree_oid(get_commit_tree_oid(parent), get_commit_tree_oid(commit), "", &revs->diffopt);
+ diff_tree_oid(parent_tree, get_commit_tree_oid(commit), "", &revs->diffopt);
diffcore_std(&revs->diffopt);
found = !diff_queue_is_empty(&revs->diffopt);