Git fork

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 <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

+23 -3
+23 -3
diff.c
··· 6814 6814 DIFF_FORMAT_NAME | 6815 6815 DIFF_FORMAT_NAME_STATUS | 6816 6816 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 + } 6817 6827 for (i = 0; i < q->nr; i++) { 6818 6828 struct diff_filepair *p = q->queue[i]; 6819 6829 6820 6830 if (!check_pair_status(p)) 6821 6831 continue; 6822 6832 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; 6826 6836 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 + } 6827 6843 flush_one_pair(p, options); 6844 + } 6845 + if (options->flags.diff_from_contents) { 6846 + fclose(dev_null); 6847 + options->color_moved = saved_color_moved; 6828 6848 } 6829 6849 separator++; 6830 6850 }