Skip to content

Commit 2a63358

Browse files
committed
show: skip diff when possible
Running: git show -s $commit will still compute a diff for $commit, even though we aren't going to show it. This is wasted computation, since it cannot affect the output or exit code of the program. In the more general case: - if the requested diff format is NO_OUTPUT, then we won't change the output of the diff itself - if rev_info.always_show_header is set, then we will show the commit regardless of whether the diff is empty (which is true for git-show, for example, but not git-log) - we don't use --exit-code here (should check?)
1 parent 68cb7f9 commit 2a63358

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

log-tree.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,6 +1105,10 @@ static int log_tree_diff(struct rev_info *opt, struct commit *commit, struct log
11051105
if (!all_need_diff && !opt->merges_need_diff)
11061106
return 0;
11071107

1108+
if (opt->diffopt.output_format == DIFF_FORMAT_NO_OUTPUT &&
1109+
opt->always_show_header)
1110+
return 0;
1111+
11081112
parse_commit_or_die(commit);
11091113
oid = get_commit_tree_oid(commit);
11101114

0 commit comments

Comments
 (0)