@@ -3399,6 +3399,21 @@ static void add_formatted_headers(struct strbuf *msg,
3399
3399
line_prefix , meta , reset );
3400
3400
}
3401
3401
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
+
3402
3417
static void builtin_diff (const char * name_a ,
3403
3418
const char * name_b ,
3404
3419
struct diff_filespec * one ,
@@ -3430,14 +3445,16 @@ static void builtin_diff(const char *name_a,
3430
3445
3431
3446
if (o -> submodule_format == DIFF_SUBMODULE_LOG &&
3432
3447
(!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 ))) {
3434
3450
show_submodule_diff_summary (o , one -> path ? one -> path : two -> path ,
3435
3451
& one -> oid , & two -> oid ,
3436
3452
two -> dirty_submodule );
3437
3453
return ;
3438
3454
} else if (o -> submodule_format == DIFF_SUBMODULE_INLINE_DIFF &&
3439
3455
(!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 ))) {
3441
3458
show_submodule_inline_diff (o , one -> path ? one -> path : two -> path ,
3442
3459
& one -> oid , & two -> oid ,
3443
3460
two -> dirty_submodule );
@@ -3457,12 +3474,12 @@ static void builtin_diff(const char *name_a,
3457
3474
b_two = quote_two (b_prefix , name_b + (* name_b == '/' ));
3458
3475
lbl [0 ] = DIFF_FILE_VALID (one ) ? a_one : "/dev/null" ;
3459
3476
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 )) {
3461
3478
/*
3462
- * We should only reach this point for pairs from
3479
+ * We should only reach this point for pairs generated from
3463
3480
* 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
3466
3483
* "new file" or "deleted file" below.
3467
3484
*/
3468
3485
lbl [0 ] = a_one ;
@@ -5853,6 +5870,7 @@ static void diff_flush_patch(struct diff_filepair *p, struct diff_options *o)
5853
5870
{
5854
5871
int include_conflict_headers =
5855
5872
(additional_headers (o , p -> one -> path ) &&
5873
+ !o -> pickaxe_opts &&
5856
5874
(!o -> filter || filter_bit_tst (DIFF_STATUS_UNMERGED , o )));
5857
5875
5858
5876
/*
@@ -5908,6 +5926,8 @@ int diff_queue_is_empty(struct diff_options *o)
5908
5926
int i ;
5909
5927
int include_conflict_headers =
5910
5928
(o -> additional_path_headers &&
5929
+ strmap_get_size (o -> additional_path_headers ) &&
5930
+ !o -> pickaxe_opts &&
5911
5931
(!o -> filter || filter_bit_tst (DIFF_STATUS_UNMERGED , o )));
5912
5932
5913
5933
if (include_conflict_headers )
0 commit comments