Skip to content

Commit e56c419

Browse files
committed
Merge branch 'jk/diff-from-contents-fix' into maint-2.51
Recently we attempted to improve "git diff -w" and friends to handle cases where patch output would be suppressed, but it introduced a bug that emits unnecessary output, which has been corrected. * jk/diff-from-contents-fix: diff: restore redirection to /dev/null for diff_from_contents
2 parents 81f86aa + 623f7af commit e56c419

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

diff.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6876,6 +6876,15 @@ void diff_flush(struct diff_options *options)
68766876
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
68776877
options->flags.exit_with_status &&
68786878
options->flags.diff_from_contents) {
6879+
/*
6880+
* run diff_flush_patch for the exit status. setting
6881+
* options->file to /dev/null should be safe, because we
6882+
* aren't supposed to produce any output anyway.
6883+
*/
6884+
diff_free_file(options);
6885+
options->file = xfopen("/dev/null", "w");
6886+
options->close_file = 1;
6887+
options->color_moved = 0;
68796888
for (i = 0; i < q->nr; i++) {
68806889
struct diff_filepair *p = q->queue[i];
68816890
if (check_pair_status(p))

t/t4035-diff-quiet.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ test_expect_success 'git diff-tree HEAD HEAD' '
5050
test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt &&
5151
test_line_count = 0 cnt
5252
'
53+
test_expect_success 'git diff-tree -w HEAD^ HEAD' '
54+
test_expect_code 1 git diff-tree --quiet -w HEAD^ HEAD >cnt &&
55+
test_line_count = 0 cnt
56+
'
5357
test_expect_success 'git diff-files' '
5458
test_expect_code 0 git diff-files --quiet >cnt &&
5559
test_line_count = 0 cnt

0 commit comments

Comments
 (0)