summaryrefslogtreecommitdiff
path: root/combine-diff.c
diff options
context:
space:
mode:
authorKirill Smelkov <kirr@mns.spb.ru>2014-02-03 16:47:19 +0400
committerJunio C Hamano <gitster@pobox.com>2014-02-24 14:46:11 -0800
commit51af1886c73f12b1e020db1aa03525e2d74bed93 (patch)
tree03ad8f172d72fdf21f5d2203196ee152385e5d4a /combine-diff.c
parentfce135c4ffc87f85e1c3b5c57a6d9e1abdbd074d (diff)
downloadgit-51af1886c73f12b1e020db1aa03525e2d74bed93.tar.gz
combine-diff: move show_log_first logic/action out of paths scanning
Judging from sample outputs and tests nothing changes in diff -c output, and this change will help later patches, when we'll be refactoring paths scanning into its own function with several variants - the show_log_first logic / code will stay common to all of them. NOTE: only now we have to take care to explicitly not show anything if parents array is empty, as in fact there are some clients in Git code, which calls diff_tree_combined() in such a way. Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'combine-diff.c')
-rw-r--r--combine-diff.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/combine-diff.c b/combine-diff.c
index 24ca7e2334..68d2e53be6 100644
--- a/combine-diff.c
+++ b/combine-diff.c
@@ -1311,6 +1311,20 @@ void diff_tree_combined(const unsigned char *sha1,
struct combine_diff_path *p, *paths = NULL;
int i, num_paths, needsep, show_log_first, num_parent = parents->nr;
+ /* nothing to do, if no parents */
+ if (!num_parent)
+ return;
+
+ show_log_first = !!rev->loginfo && !rev->no_commit_id;
+ needsep = 0;
+ if (show_log_first) {
+ show_log(rev);
+
+ if (rev->verbose_header && opt->output_format)
+ printf("%s%c", diff_line_prefix(opt),
+ opt->line_termination);
+ }
+
diffopts = *opt;
copy_pathspec(&diffopts.pathspec, &opt->pathspec);
diffopts.output_format = DIFF_FORMAT_NO_OUTPUT;
@@ -1319,8 +1333,6 @@ void diff_tree_combined(const unsigned char *sha1,
/* tell diff_tree to emit paths in sorted (=tree) order */
diffopts.orderfile = NULL;
- show_log_first = !!rev->loginfo && !rev->no_commit_id;
- needsep = 0;
/* find set of paths that everybody touches */
for (i = 0; i < num_parent; i++) {
/* show stat against the first parent even
@@ -1336,14 +1348,6 @@ void diff_tree_combined(const unsigned char *sha1,
diffcore_std(&diffopts);
paths = intersect_paths(paths, i, num_parent);
- if (show_log_first && i == 0) {
- show_log(rev);
-
- if (rev->verbose_header && opt->output_format)
- printf("%s%c", diff_line_prefix(opt),
- opt->line_termination);
- }
-
/* if showing diff, show it in requested order */
if (diffopts.output_format != DIFF_FORMAT_NO_OUTPUT &&
opt->orderfile) {