Git fork

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

+23 -3
+23 -3
diff.c
··· 6828 DIFF_FORMAT_NAME | 6829 DIFF_FORMAT_NAME_STATUS | 6830 DIFF_FORMAT_CHECKDIFF)) { 6831 for (i = 0; i < q->nr; i++) { 6832 struct diff_filepair *p = q->queue[i]; 6833 6834 if (!check_pair_status(p)) 6835 continue; 6836 6837 - if (options->flags.diff_from_contents && 6838 - !diff_flush_patch_quietly(p, options)) 6839 - continue; 6840 6841 flush_one_pair(p, options); 6842 } 6843 separator++; 6844 }
··· 6828 DIFF_FORMAT_NAME | 6829 DIFF_FORMAT_NAME_STATUS | 6830 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 + } 6841 for (i = 0; i < q->nr; i++) { 6842 struct diff_filepair *p = q->queue[i]; 6843 6844 if (!check_pair_status(p)) 6845 continue; 6846 6847 + if (options->flags.diff_from_contents) { 6848 + FILE *saved_file = options->file; 6849 + int found_changes; 6850 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 + } 6857 flush_one_pair(p, options); 6858 + } 6859 + if (options->flags.diff_from_contents) { 6860 + fclose(dev_null); 6861 + options->color_moved = saved_color_moved; 6862 } 6863 separator++; 6864 }