Skip to content

Commit 48799d1

Browse files
committed
Merge branch 'tr/log-tree-optim'
Optimize "log" that shows the difference between the parent and the child. * tr/log-tree-optim: Avoid loading commits twice in log with diffs
2 parents 76d1ab3 + d1b9b76 commit 48799d1

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

log-tree.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -709,11 +709,14 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
709709
{
710710
int showed_log;
711711
struct commit_list *parents;
712-
unsigned const char *sha1 = commit->object.sha1;
712+
unsigned const char *sha1;
713713

714714
if (!opt->diff && !DIFF_OPT_TST(&opt->diffopt, EXIT_WITH_STATUS))
715715
return 0;
716716

717+
parse_commit(commit);
718+
sha1 = commit->tree->object.sha1;
719+
717720
/* Root commit? */
718721
parents = commit->parents;
719722
if (!parents) {
@@ -736,7 +739,9 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
736739
* parent, showing summary diff of the others
737740
* we merged _in_.
738741
*/
739-
diff_tree_sha1(parents->item->object.sha1, sha1, "", &opt->diffopt);
742+
parse_commit(parents->item);
743+
diff_tree_sha1(parents->item->tree->object.sha1,
744+
sha1, "", &opt->diffopt);
740745
log_tree_diff_flush(opt);
741746
return !opt->loginfo;
742747
}
@@ -749,7 +754,9 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
749754
for (;;) {
750755
struct commit *parent = parents->item;
751756

752-
diff_tree_sha1(parent->object.sha1, sha1, "", &opt->diffopt);
757+
parse_commit(parent);
758+
diff_tree_sha1(parent->tree->object.sha1,
759+
sha1, "", &opt->diffopt);
753760
log_tree_diff_flush(opt);
754761

755762
showed_log |= !opt->loginfo;

0 commit comments

Comments
 (0)