Skip to content

Commit 71a146d

Browse files
newrengitster
authored andcommitted
diff: fix filtering of additional headers 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, when the pickaxe is active, we really only want the remerge conflict headers to be shown when there is an associated content diff. Adjust the logic in these two functions accordingly. This also removes the TEST_PASSES_SANITIZE_LEAK=true declaration from t4069, as there is apparently some kind of memory leak with the pickaxe code. Signed-off-by: Elijah Newren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 9b08091 commit 71a146d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

diff.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5869,6 +5869,7 @@ static void diff_flush_patch(struct diff_filepair *p, struct diff_options *o)
58695869
{
58705870
int include_conflict_headers =
58715871
(additional_headers(o, p->one->path) &&
5872+
!o->pickaxe_opts &&
58725873
(!o->filter || filter_bit_tst(DIFF_STATUS_UNMERGED, o)));
58735874

58745875
/*
@@ -5924,6 +5925,7 @@ int diff_queue_is_empty(struct diff_options *o)
59245925
int i;
59255926
int include_conflict_headers =
59265927
(o->additional_path_headers &&
5928+
!o->pickaxe_opts &&
59275929
(!o->filter || filter_bit_tst(DIFF_STATUS_UNMERGED, o)));
59285930

59295931
if (include_conflict_headers)

t/t4069-remerge-diff.sh

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
test_description='remerge-diff handling'
44

5-
TEST_PASSES_SANITIZE_LEAK=true
65
. ./test-lib.sh
76

87
# This test is ort-specific
@@ -90,6 +89,22 @@ test_expect_success 'remerge-diff with both a resolved conflict and an unrelated
9089
test_cmp expect actual
9190
'
9291

92+
test_expect_success 'pickaxe still includes additional headers for relevant changes' '
93+
# reuses "expect" from the previous testcase
94+
95+
git log --oneline --remerge-diff -Sacht ab_resolution >tmp &&
96+
sed -e "s/[0-9a-f]\{7,\}/HASH/g" tmp >actual &&
97+
test_cmp expect actual
98+
'
99+
100+
test_expect_success 'can filter out additional headers with pickaxe' '
101+
git show --remerge-diff --submodule=log --find-object=HEAD ab_resolution >actual &&
102+
test_must_be_empty actual &&
103+
104+
git show --remerge-diff -S"not present" --all >actual &&
105+
test_must_be_empty actual
106+
'
107+
93108
test_expect_success 'setup non-content conflicts' '
94109
git switch --orphan base &&
95110

0 commit comments

Comments
 (0)