diff: fix filtering of additional headers under --remerge-diff

Commit 95433eeed9 ("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 <newren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Elijah Newren committed Sep 2, 2022 at 03:53 UTC 71a146dc701931363d78aa21ad215da648252617
2 files changed +18 -1
diff.c
+2
@@ -5869,6 +5869,7 @@ static void diff_flush_patch(struct diff_filepair *p, struct diff_options *o)
5869 {
5870 int include_conflict_headers =
5871 (additional_headers(o, p->one->path) &&
5872 + !o->pickaxe_opts &&
5873 (!o->filter || filter_bit_tst(DIFF_STATUS_UNMERGED, o)));
5874
5875 /*
@@ -5924,6 +5925,7 @@ int diff_queue_is_empty(struct diff_options *o)
5925 int i;
5926 int include_conflict_headers =
5927 (o->additional_path_headers &&
5928 + !o->pickaxe_opts &&
5929 (!o->filter || filter_bit_tst(DIFF_STATUS_UNMERGED, o)));
5930
5931 if (include_conflict_headers)
t/t4069-remerge-diff.sh
+16 -1
@@ -2,7 +2,6 @@
2
3 test_description='remerge-diff handling'
4
5 -TEST_PASSES_SANITIZE_LEAK=true
5 . ./test-lib.sh
6
7 # This test is ort-specific
@@ -90,6 +89,22 @@ test_expect_success 'remerge-diff with both a resolved conflict and an unrelated
89 test_cmp expect actual
90 '
91
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 +
108 test_expect_success 'setup non-content conflicts' '
109 git switch --orphan base &&
110