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

[PATCH] unresolve: make sure resolve-undo info is left even for removed paths

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 22, 2023, 22:54 UTC
Message-ID
<xmqqzg4rcdlb.fsf@gitster.g>

"git rerere forget" requires that resolve-undo information is correctly recorded in the index.

The current rerere machinery is not even prepared to access the resolve-undo information for paths resolved for removal, as it first goes to the main index entry and then finds the resolve-undo information associated to the same pathname. This has to be fixed later (the codepath used by "git update-index --unresolve" shares the same problem---unmerge_index_entry_at() is a flawed interface that assumes that the index has the path in it after resolution, and cannot be used when the resolution was to remove), but let's first make sure we have the information recorded.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 t/t2030-unresolve-info.sh | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)
diff --git a/t/t2030-unresolve-info.sh b/t/t2030-unresolve-info.sh
index 2d8c70b03a..c515b40e8d 100755
--- a/t/t2030-unresolve-info.sh
+++ b/t/t2030-unresolve-info.sh
@@ -62,6 +62,13 @@ test_expect_success setup '
 	test_commit fourth fi/le fourth &&
 	git checkout add-add &&
 	test_commit fifth add-differently &&
+	git checkout --detach initial &&
+	git rm binary &&
+	test_commit sixth del-binary &&
+	git reset --hard HEAD^ &&
+	printf "a\0c" >binary &&
+	git add binary &&
+	test_commit seventh mod-binary &&
 	git checkout main
 '
 
@@ -126,6 +133,32 @@ test_expect_success 'unmerge with plumbing' '
 	test_line_count = 3 actual
 '
 
+test_expect_success 'del-mod conflict' '
+	git reset --hard &&
+	# they delete, we modify, resolve to ours
+	git checkout --detach seventh &&
+	test_must_fail git merge sixth &&
+	git add binary &&
+	check_resolve_undo mods binary initial:binary seventh:binary ""
+'
+
+test_expect_success 'del-mod conflict' '
+	git reset --hard &&
+	# we delete, they modify, resolve to deletion
+	git checkout --detach sixth &&
+	test_must_fail git merge seventh &&
+	git rm binary &&
+	check_resolve_undo removed binary initial:binary "" seventh:binary
+'
+
+test_expect_success 'resolve 3-way conflict to deletion' '
+	git reset --hard &&
+	git checkout --detach second &&
+	test_must_fail git merge third &&
+	git rm fi/le &&
+	check_resolve_undo recorded fi/le initial:fi/le second:fi/le third:fi/le
+'
+
 test_expect_success 'rerere and rerere forget' '
 	mkdir .git/rr-cache &&
 	prime_resolve_undo &&
-- 
2.41.0-113-g6640c2d06d
Message 1 of 1 in “unresolve: make sure resolve-undo info is left even for removed paths”
  1. unresolve: make sure resolve-undo info is left even for removed pathsJunio C Hamano, Jun 22, 2023

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.