Skip to content

Commit 88b3704

Browse files
committed
Merge branch 'jk/diff-from-contents-fix'
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 c54a18e + 623f7af commit 88b3704

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
@@ -6890,6 +6890,15 @@ void diff_flush(struct diff_options *options)
68906890
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
68916891
options->flags.exit_with_status &&
68926892
options->flags.diff_from_contents) {
6893+
/*
6894+
* run diff_flush_patch for the exit status. setting
6895+
* options->file to /dev/null should be safe, because we
6896+
* aren't supposed to produce any output anyway.
6897+
*/
6898+
diff_free_file(options);
6899+
options->file = xfopen("/dev/null", "w");
6900+
options->close_file = 1;
6901+
options->color_moved = 0;
68936902
for (i = 0; i < q->nr; i++) {
68946903
struct diff_filepair *p = q->queue[i];
68956904
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)