Skip to content

Commit 67360b7

Browse files
newrengitster
authored andcommitted
diff: fix filtering of merge commits under --remerge-diff
Commit 95433ee ("diff: add ability to insert additional headers for paths", 2022-02-02) introduced the possibility of additional headers. Because there could be conflicts with no content differences (e.g. a modify/delete conflict resolved in favor of taking the modified file as-is), that commit also modified the diff_queue_is_empty() and diff_flush_patch() logic to ensure these headers were included even if there was no associated content diff. However, the added logic was a bit inconsistent between these two functions. diff_queue_is_empty() overlooked the fact that the additional headers strmap could be non-NULL and empty, which would cause it to display commits that should have been filtered out. Fix the diff_queue_is_empty() logic to also account for additional_path_headers being empty. Reported-by: Philippe Blain <[email protected]> Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 71a146d commit 67360b7

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5925,6 +5925,7 @@ int diff_queue_is_empty(struct diff_options *o)
59255925
int i;
59265926
int include_conflict_headers =
59275927
(o->additional_path_headers &&
5928+
strmap_get_size(o->additional_path_headers) &&
59285929
!o->pickaxe_opts &&
59295930
(!o->filter || filter_bit_tst(DIFF_STATUS_UNMERGED, o)));
59305931

t/t4069-remerge-diff.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,11 @@ test_expect_success 'remerge-diff on a clean merge' '
5656
test_cmp expect actual
5757
'
5858

59+
test_expect_success 'remerge-diff on a clean merge with a filter' '
60+
git show --oneline --remerge-diff --diff-filter=U bc_resolution >actual &&
61+
test_must_be_empty actual
62+
'
63+
5964
test_expect_success 'remerge-diff with both a resolved conflict and an unrelated change' '
6065
git log -1 --oneline ab_resolution >tmp &&
6166
cat <<-EOF >>tmp &&

0 commit comments

Comments
 (0)