Skip to content

Commit 5139fce

Browse files
committed
Merge branch 'jc/diff-from-contents-fix'
The code to squelch output from "git diff -w --name-status" etc. for paths that "git diff -w -p" would have stayed silent leaked output from dry-run patch generation, which has been corrected. * jc/diff-from-contents-fix: diff: make sure the other caller of diff_flush_patch_quietly() is silent
2 parents 88b3704 + 3da4413 commit 5139fce

File tree

1 file changed

+23
-3
lines changed

1 file changed

+23
-3
lines changed

diff.c

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6828,18 +6828,38 @@ void diff_flush(struct diff_options *options)
68286828
DIFF_FORMAT_NAME |
68296829
DIFF_FORMAT_NAME_STATUS |
68306830
DIFF_FORMAT_CHECKDIFF)) {
6831+
/*
6832+
* make sure diff_Flush_patch_quietly() to be silent.
6833+
*/
6834+
FILE *dev_null = NULL;
6835+
int saved_color_moved = options->color_moved;
6836+
6837+
if (options->flags.diff_from_contents) {
6838+
dev_null = xfopen("/dev/null", "w");
6839+
options->color_moved = 0;
6840+
}
68316841
for (i = 0; i < q->nr; i++) {
68326842
struct diff_filepair *p = q->queue[i];
68336843

68346844
if (!check_pair_status(p))
68356845
continue;
68366846

6837-
if (options->flags.diff_from_contents &&
6838-
!diff_flush_patch_quietly(p, options))
6839-
continue;
6847+
if (options->flags.diff_from_contents) {
6848+
FILE *saved_file = options->file;
6849+
int found_changes;
68406850

6851+
options->file = dev_null;
6852+
found_changes = diff_flush_patch_quietly(p, options);
6853+
options->file = saved_file;
6854+
if (!found_changes)
6855+
continue;
6856+
}
68416857
flush_one_pair(p, options);
68426858
}
6859+
if (options->flags.diff_from_contents) {
6860+
fclose(dev_null);
6861+
options->color_moved = saved_color_moved;
6862+
}
68436863
separator++;
68446864
}
68456865

0 commit comments

Comments
 (0)