Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Documentation/RelNotes/2.52.0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ including security updates, are included in this release.
ignored") did not work well with "--name-only" and friends.
(merge b55e6d36eb ly/diff-name-only-with-diff-from-content later to maint).

* The above caused regressions, which has been corrected.
(merge 623f7af2 jk/diff-from-contents-fix later to maint).
(merge 3da4413d jc/diff-from-contents-fix later to maint).

* Documentation for "git rebase" has been updated.
(merge 3f7f2b0359 je/doc-rebase later to maint).

Expand Down
35 changes: 32 additions & 3 deletions diff.c
Original file line number Diff line number Diff line change
Expand Up @@ -6828,18 +6828,38 @@ void diff_flush(struct diff_options *options)
DIFF_FORMAT_NAME |
DIFF_FORMAT_NAME_STATUS |
DIFF_FORMAT_CHECKDIFF)) {
/*
* make sure diff_Flush_patch_quietly() to be silent.
*/
FILE *dev_null = NULL;
int saved_color_moved = options->color_moved;

if (options->flags.diff_from_contents) {
dev_null = xfopen("/dev/null", "w");
options->color_moved = 0;
}
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];

if (!check_pair_status(p))
continue;

if (options->flags.diff_from_contents &&
!diff_flush_patch_quietly(p, options))
continue;
if (options->flags.diff_from_contents) {
FILE *saved_file = options->file;
int found_changes;

options->file = dev_null;
found_changes = diff_flush_patch_quietly(p, options);
options->file = saved_file;
if (!found_changes)
continue;
}
flush_one_pair(p, options);
}
if (options->flags.diff_from_contents) {
fclose(dev_null);
options->color_moved = saved_color_moved;
}
separator++;
}

Expand Down Expand Up @@ -6890,6 +6910,15 @@ void diff_flush(struct diff_options *options)
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
options->flags.exit_with_status &&
options->flags.diff_from_contents) {
/*
* run diff_flush_patch for the exit status. setting
* options->file to /dev/null should be safe, because we
* aren't supposed to produce any output anyway.
*/
diff_free_file(options);
options->file = xfopen("/dev/null", "w");
options->close_file = 1;
options->color_moved = 0;
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
if (check_pair_status(p))
Expand Down
4 changes: 4 additions & 0 deletions t/t4035-diff-quiet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ test_expect_success 'git diff-tree HEAD HEAD' '
test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt &&
test_line_count = 0 cnt
'
test_expect_success 'git diff-tree -w HEAD^ HEAD' '
test_expect_code 1 git diff-tree --quiet -w HEAD^ HEAD >cnt &&
test_line_count = 0 cnt
'
test_expect_success 'git diff-files' '
test_expect_code 0 git diff-files --quiet >cnt &&
test_line_count = 0 cnt
Expand Down