@@ -3563,18 +3563,21 @@ static void builtin_diff(const char *name_a,
3563
3563
strbuf_addf (& header , "%s%snew file mode %06o%s\n" , line_prefix , meta , two -> mode , reset );
3564
3564
if (xfrm_msg )
3565
3565
strbuf_addstr (& header , xfrm_msg );
3566
+ o -> found_changes = 1 ;
3566
3567
must_show_header = 1 ;
3567
3568
}
3568
3569
else if (lbl [1 ][0 ] == '/' ) {
3569
3570
strbuf_addf (& header , "%s%sdeleted file mode %06o%s\n" , line_prefix , meta , one -> mode , reset );
3570
3571
if (xfrm_msg )
3571
3572
strbuf_addstr (& header , xfrm_msg );
3573
+ o -> found_changes = 1 ;
3572
3574
must_show_header = 1 ;
3573
3575
}
3574
3576
else {
3575
3577
if (one -> mode != two -> mode ) {
3576
3578
strbuf_addf (& header , "%s%sold mode %06o%s\n" , line_prefix , meta , one -> mode , reset );
3577
3579
strbuf_addf (& header , "%s%snew mode %06o%s\n" , line_prefix , meta , two -> mode , reset );
3580
+ o -> found_changes = 1 ;
3578
3581
must_show_header = 1 ;
3579
3582
}
3580
3583
if (xfrm_msg )
@@ -4832,6 +4835,10 @@ void diff_setup_done(struct diff_options *options)
4832
4835
else
4833
4836
options -> prefix_length = 0 ;
4834
4837
4838
+ /*
4839
+ * --name-only, --name-status, --checkdiff, and -s
4840
+ * turn other output format off.
4841
+ */
4835
4842
if (options -> output_format & (DIFF_FORMAT_NAME |
4836
4843
DIFF_FORMAT_NAME_STATUS |
4837
4844
DIFF_FORMAT_CHECKDIFF |
@@ -6206,6 +6213,8 @@ static void flush_one_pair(struct diff_filepair *p, struct diff_options *opt)
6206
6213
fprintf (opt -> file , "%s" , diff_line_prefix (opt ));
6207
6214
write_name_quoted (name_a , opt -> file , opt -> line_termination );
6208
6215
}
6216
+
6217
+ opt -> found_changes = 1 ;
6209
6218
}
6210
6219
6211
6220
static void show_file_mode_name (struct diff_options * opt , const char * newdelete , struct diff_filespec * fs )
@@ -6684,6 +6693,21 @@ void diff_flush(struct diff_options *options)
6684
6693
separator ++ ;
6685
6694
}
6686
6695
6696
+ if (output_format & DIFF_FORMAT_PATCH ) {
6697
+ if (separator ) {
6698
+ emit_diff_symbol (options , DIFF_SYMBOL_SEPARATOR , NULL , 0 , 0 );
6699
+ if (options -> stat_sep )
6700
+ /* attach patch instead of inline */
6701
+ emit_diff_symbol (options , DIFF_SYMBOL_STAT_SEP ,
6702
+ NULL , 0 , 0 );
6703
+ }
6704
+
6705
+ diff_flush_patch_all_file_pairs (options );
6706
+ }
6707
+
6708
+ if (output_format & DIFF_FORMAT_CALLBACK )
6709
+ options -> format_callback (q , options , options -> format_callback_data );
6710
+
6687
6711
if (output_format & DIFF_FORMAT_NO_OUTPUT &&
6688
6712
options -> flags .exit_with_status &&
6689
6713
options -> flags .diff_from_contents ) {
@@ -6705,21 +6729,6 @@ void diff_flush(struct diff_options *options)
6705
6729
}
6706
6730
}
6707
6731
6708
- if (output_format & DIFF_FORMAT_PATCH ) {
6709
- if (separator ) {
6710
- emit_diff_symbol (options , DIFF_SYMBOL_SEPARATOR , NULL , 0 , 0 );
6711
- if (options -> stat_sep )
6712
- /* attach patch instead of inline */
6713
- emit_diff_symbol (options , DIFF_SYMBOL_STAT_SEP ,
6714
- NULL , 0 , 0 );
6715
- }
6716
-
6717
- diff_flush_patch_all_file_pairs (options );
6718
- }
6719
-
6720
- if (output_format & DIFF_FORMAT_CALLBACK )
6721
- options -> format_callback (q , options , options -> format_callback_data );
6722
-
6723
6732
free_queue :
6724
6733
diff_free_queue (q );
6725
6734
DIFF_QUEUE_CLEAR (q );
@@ -7029,6 +7038,7 @@ void compute_diffstat(struct diff_options *options,
7029
7038
if (check_pair_status (p ))
7030
7039
diff_flush_stat (p , options , diffstat );
7031
7040
}
7041
+ options -> found_changes = !!diffstat -> nr ;
7032
7042
}
7033
7043
7034
7044
void diff_addremove (struct diff_options * options ,
0 commit comments