Merge branch 'tr/log-tree-optim'
authorJunio C Hamano <gitster@pobox.com>
Tue, 2 Apr 2013 22:10:46 +0000 (15:10 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Apr 2013 22:10:46 +0000 (15:10 -0700)
Optimize "log" that shows the difference between the parent and the
child.

* tr/log-tree-optim:
Avoid loading commits twice in log with diffs

log-tree.c
index 92bb2bf48e641ee6161a0e10dd87d9ce06632f7c..7cc7d598e712fab531f7c6f938be17c317161f3e 100644 (file)
@@ -709,11 +709,14 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
 {
        int showed_log;
        struct commit_list *parents;
-       unsigned const char *sha1 = commit->object.sha1;
+       unsigned const char *sha1;
 
        if (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))
                return 0;
 
+       parse_commit(commit);
+       sha1 = commit->tree->object.sha1;
+
        /* Root commit? */
        parents = commit->parents;
        if (!parents) {
@@ -736,7 +739,9 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
                         * parent, showing summary diff of the others
                         * we merged _in_.
                         */
-                       diff_tree_sha1(parents->item->object.sha1, sha1, "", &opt->diffopt);
+                       parse_commit(parents->item);
+                       diff_tree_sha1(parents->item->tree->object.sha1,
+                                      sha1, "", &opt->diffopt);
                        log_tree_diff_flush(opt);
                        return !opt->loginfo;
                }
@@ -749,7 +754,9 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
        for (;;) {
                struct commit *parent = parents->item;
 
-               diff_tree_sha1(parent->object.sha1, sha1, "", &opt->diffopt);
+               parse_commit(parent);
+               diff_tree_sha1(parent->tree->object.sha1,
+                              sha1, "", &opt->diffopt);
                log_tree_diff_flush(opt);
 
                showed_log |= !opt->loginfo;