Skip to content

Commit

Permalink
Merge branch 'tr/log-tree-optim'
Browse files Browse the repository at this point in the history
Optimize "log" that shows the difference between the parent and the
child.

* tr/log-tree-optim:
  Avoid loading commits twice in log with diffs
  • Loading branch information
Junio C Hamano committed Apr 2, 2013
2 parents 76d1ab3 + d1b9b76 commit 48799d1
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions log-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down

0 comments on commit 48799d1

Please sign in to comment.