]> git.ipfire.org Git - thirdparty/git.git/commitdiff
diff: fix filtering of merge commits under --remerge-diff
authorElijah Newren <newren@gmail.com>
Fri, 2 Sep 2022 03:53:30 +0000 (03:53 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 2 Sep 2022 16:22:25 +0000 (09:22 -0700)
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, 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 <levraiphilippeblain@gmail.com>
Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4069-remerge-diff.sh

diff --git a/diff.c b/diff.c
index 2439310ae1fe2f87eefe3a4589a69ce4f6bd338f..e1f9cef2f38014531a3f5af9f8e7cc001ee4daf3 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -5925,6 +5925,7 @@ int diff_queue_is_empty(struct diff_options *o)
        int i;
        int include_conflict_headers =
            (o->additional_path_headers &&
+            strmap_get_size(o->additional_path_headers) &&
             !o->pickaxe_opts &&
             (!o->filter || filter_bit_tst(DIFF_STATUS_UNMERGED, o)));
 
index 95a16d19aec791de7067f29890414414a8b50e9c..07323ebafe0d0cb49f08c4396116fa1f45687cd8 100755 (executable)
@@ -56,6 +56,11 @@ test_expect_success 'remerge-diff on a clean merge' '
        test_cmp expect actual
 '
 
+test_expect_success 'remerge-diff on a clean merge with a filter' '
+       git show --oneline --remerge-diff --diff-filter=U bc_resolution >actual &&
+       test_must_be_empty actual
+'
+
 test_expect_success 'remerge-diff with both a resolved conflict and an unrelated change' '
        git log -1 --oneline ab_resolution >tmp &&
        cat <<-EOF >>tmp &&