git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 3/3] diff: fix filtering of merge commits under --remerge-diff

From
Elijah Newren via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 2, 2022, 03:53 UTC
Message-ID
<084a037756d79d569c19bd85f30bae97b15ec26f.1662090810.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1342.v3.git.1662090810.gitgitgadget@gmail.com>
From: Elijah Newren <newren@gmail.com>

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>
---
 diff.c                  | 1 +
 t/t4069-remerge-diff.sh | 5 +++++
 2 files changed, 6 insertions(+)
diff --git a/diff.c b/diff.c
index 2439310ae1f..e1f9cef2f38 100644
--- 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)));
 
diff --git a/t/t4069-remerge-diff.sh b/t/t4069-remerge-diff.sh
index 95a16d19aec..07323ebafe0 100755
--- a/t/t4069-remerge-diff.sh
+++ b/t/t4069-remerge-diff.sh
@@ -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 &&
-- 
gitgitgadget
Previous: Elijah Newren via GitGitGadgetNext: Elijah Newren via GitGitGadget
Message 22 of 23 in “Output fixes for --remerge-diff”
  1. 0/3 Output fixes for --remerge-diffElijah Newren via GitGitGadget, Aug 31, 2022
  2. 1/3 diff: have submodule_format logic avoid additional diff headersElijah Newren via GitGitGadget, Aug 31, 2022
  3. Junio C HamanoAug 31, 2022
  4. Elijah NewrenSep 1, 2022
  5. 2/3 diff: fix filtering of additional headers under --remerge-diffElijah Newren via GitGitGadget, Aug 31, 2022
  6. Junio C HamanoAug 31, 2022
  7. Elijah NewrenSep 1, 2022
  8. 3/3 diff: fix filtering of merge commits under --remerge-diffElijah Newren via GitGitGadget, Aug 31, 2022
  9. Junio C HamanoSep 1, 2022
  10. Elijah NewrenSep 1, 2022
  11. Elijah NewrenSep 1, 2022
  12. Junio C HamanoSep 1, 2022
  13. Ævar Arnfjörð BjarmasonSep 1, 2022
  14. Junio C HamanoSep 1, 2022
  15. 0/3 Output fixes for --remerge-diffElijah Newren via GitGitGadget, Sep 1, 2022
  16. 1/3 diff: have submodule_format logic avoid additional diff headersElijah Newren via GitGitGadget, Sep 1, 2022
  17. Junio C HamanoSep 1, 2022
  18. 2/3 diff: fix filtering of additional headers under --remerge-diffElijah Newren via GitGitGadget, Sep 1, 2022
  19. 3/3 diff: fix filtering of merge commits under --remerge-diffElijah Newren via GitGitGadget, Sep 1, 2022
  20. 0/3 Output fixes for --remerge-diffElijah Newren via GitGitGadget, Sep 2, 2022
  21. 1/3 diff: have submodule_format logic avoid additional diff headersElijah Newren via GitGitGadget, Sep 2, 2022
  22. 3/3 diff: fix filtering of merge commits under --remerge-diffElijah Newren via GitGitGadget, Sep 2, 2022
  23. 2/3 diff: fix filtering of additional headers under --remerge-diffElijah Newren via GitGitGadget, Sep 2, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.