From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH] unresolve: make sure resolve-undo info is left even for removed paths
Date: Thu, 22 Jun 2023 15:54:40 -0700 [thread overview]
Message-ID: <xmqqzg4rcdlb.fsf@gitster.g> (raw)
"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
reply other threads:[~2023-06-22 22:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqzg4rcdlb.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).