Skip to content

Commit 3da4413

Browse files
committed
diff: make sure the other caller of diff_flush_patch_quietly() is silent
Earlier, we added is a protection for the loop that computes "git diff --quiet -w" to ensure calls to the diff_flush_patch_quietly() helper stays quiet. Do the same for another loop that deals with options like "--name-status" to make calls to the same helper. Helped-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 623f7af commit 3da4413

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
@@ -6814,18 +6814,38 @@ void diff_flush(struct diff_options *options)
68146814
DIFF_FORMAT_NAME |
68156815
DIFF_FORMAT_NAME_STATUS |
68166816
DIFF_FORMAT_CHECKDIFF)) {
6817+
/*
6818+
* make sure diff_Flush_patch_quietly() to be silent.
6819+
*/
6820+
FILE *dev_null = NULL;
6821+
int saved_color_moved = options->color_moved;
6822+
6823+
if (options->flags.diff_from_contents) {
6824+
dev_null = xfopen("/dev/null", "w");
6825+
options->color_moved = 0;
6826+
}
68176827
for (i = 0; i < q->nr; i++) {
68186828
struct diff_filepair *p = q->queue[i];
68196829

68206830
if (!check_pair_status(p))
68216831
continue;
68226832

6823-
if (options->flags.diff_from_contents &&
6824-
!diff_flush_patch_quietly(p, options))
6825-
continue;
6833+
if (options->flags.diff_from_contents) {
6834+
FILE *saved_file = options->file;
6835+
int found_changes;
68266836

6837+
options->file = dev_null;
6838+
found_changes = diff_flush_patch_quietly(p, options);
6839+
options->file = saved_file;
6840+
if (!found_changes)
6841+
continue;
6842+
}
68276843
flush_one_pair(p, options);
68286844
}
6845+
if (options->flags.diff_from_contents) {
6846+
fclose(dev_null);
6847+
options->color_moved = saved_color_moved;
6848+
}
68296849
separator++;
68306850
}
68316851

0 commit comments

Comments
 (0)