Skip to content

Commit 903e09a

Browse files
committed
diff/diff-files: do not use --cc too aggressively
Textual diff output for unmerged paths was too eager to give condensed combined diff. Even though "diff -c" (and "diff-files -c -p") is a request to view combined diff without condensing (otherwise the user would have explicitly asked for --cc, not -c), we showed "--cc" output anyway. 0fe7c1d (built-in diff: assorted updates, 2006-04-29) claimed to be careful about doing this, but its breakage was hidden because back then "git diff" was still a shell script that did not use the codepath it introduced fully. Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 1f5a892 commit 903e09a

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

builtin-diff-files.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,12 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
5050
3 < rev.max_count)
5151
usage(diff_files_usage);
5252

53-
if (rev.max_count == -1 &&
53+
/*
54+
* "diff-files --base -p" should not combine merges because it
55+
* was not asked to. "diff-files -c -p" should not densify
56+
* (the user should ask with "diff-files --cc" explicitly).
57+
*/
58+
if (rev.max_count == -1 && !rev.combine_merges &&
5459
(rev.diffopt.output_format & DIFF_FORMAT_PATCH))
5560
rev.combine_merges = rev.dense_combined_merges = 1;
5661

builtin-diff.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv
223223
argv++; argc--;
224224
}
225225

226-
if (revs->max_count == -1 &&
226+
/*
227+
* "diff --base" should not combine merges because it was not
228+
* asked to. "diff -c" should not densify (if the user wants
229+
* dense one, --cc can be explicitly asked for, or just rely
230+
* on the default).
231+
*/
232+
if (revs->max_count == -1 && !revs->combine_merges &&
227233
(revs->diffopt.output_format & DIFF_FORMAT_PATCH))
228234
revs->combine_merges = revs->dense_combined_merges = 1;
229235

0 commit comments

Comments
 (0)