@@ -3399,6 +3399,21 @@ static void add_formatted_headers(struct strbuf *msg,
33993399 line_prefix , meta , reset );
34003400}
34013401
3402+ static int diff_filepair_is_phoney (struct diff_filespec * one ,
3403+ struct diff_filespec * two )
3404+ {
3405+ /*
3406+ * This function specifically looks for pairs injected by
3407+ * create_filepairs_for_header_only_notifications(). Such
3408+ * pairs are "phoney" in that they do not represent any
3409+ * content or even mode difference, but were inserted because
3410+ * diff_queued_diff previously had no pair associated with
3411+ * that path but we needed some pair to avoid losing the
3412+ * "remerge CONFLICT" header associated with the path.
3413+ */
3414+ return !DIFF_FILE_VALID (one ) && !DIFF_FILE_VALID (two );
3415+ }
3416+
34023417static void builtin_diff (const char * name_a ,
34033418 const char * name_b ,
34043419 struct diff_filespec * one ,
@@ -3430,14 +3445,16 @@ static void builtin_diff(const char *name_a,
34303445
34313446 if (o -> submodule_format == DIFF_SUBMODULE_LOG &&
34323447 (!one -> mode || S_ISGITLINK (one -> mode )) &&
3433- (!two -> mode || S_ISGITLINK (two -> mode ))) {
3448+ (!two -> mode || S_ISGITLINK (two -> mode )) &&
3449+ (!diff_filepair_is_phoney (one , two ))) {
34343450 show_submodule_diff_summary (o , one -> path ? one -> path : two -> path ,
34353451 & one -> oid , & two -> oid ,
34363452 two -> dirty_submodule );
34373453 return ;
34383454 } else if (o -> submodule_format == DIFF_SUBMODULE_INLINE_DIFF &&
34393455 (!one -> mode || S_ISGITLINK (one -> mode )) &&
3440- (!two -> mode || S_ISGITLINK (two -> mode ))) {
3456+ (!two -> mode || S_ISGITLINK (two -> mode )) &&
3457+ (!diff_filepair_is_phoney (one , two ))) {
34413458 show_submodule_inline_diff (o , one -> path ? one -> path : two -> path ,
34423459 & one -> oid , & two -> oid ,
34433460 two -> dirty_submodule );
@@ -3457,12 +3474,12 @@ static void builtin_diff(const char *name_a,
34573474 b_two = quote_two (b_prefix , name_b + (* name_b == '/' ));
34583475 lbl [0 ] = DIFF_FILE_VALID (one ) ? a_one : "/dev/null" ;
34593476 lbl [1 ] = DIFF_FILE_VALID (two ) ? b_two : "/dev/null" ;
3460- if (! DIFF_FILE_VALID (one ) && ! DIFF_FILE_VALID ( two )) {
3477+ if (diff_filepair_is_phoney (one , two )) {
34613478 /*
3462- * We should only reach this point for pairs from
3479+ * We should only reach this point for pairs generated from
34633480 * create_filepairs_for_header_only_notifications(). For
3464- * these, we should avoid the "/dev/null" special casing
3465- * above, meaning we avoid showing such pairs as either
3481+ * these, we want to avoid the "/dev/null" special casing
3482+ * above, because we do not want such pairs shown as either
34663483 * "new file" or "deleted file" below.
34673484 */
34683485 lbl [0 ] = a_one ;
@@ -5853,6 +5870,7 @@ static void diff_flush_patch(struct diff_filepair *p, struct diff_options *o)
58535870{
58545871 int include_conflict_headers =
58555872 (additional_headers (o , p -> one -> path ) &&
5873+ !o -> pickaxe_opts &&
58565874 (!o -> filter || filter_bit_tst (DIFF_STATUS_UNMERGED , o )));
58575875
58585876 /*
@@ -5908,6 +5926,8 @@ int diff_queue_is_empty(struct diff_options *o)
59085926 int i ;
59095927 int include_conflict_headers =
59105928 (o -> additional_path_headers &&
5929+ strmap_get_size (o -> additional_path_headers ) &&
5930+ !o -> pickaxe_opts &&
59115931 (!o -> filter || filter_bit_tst (DIFF_STATUS_UNMERGED , o )));
59125932
59135933 if (include_conflict_headers )
0 commit comments