From: "Dmitry Goncharov via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Dmitry Goncharov <dgoncharov@users.sf.net>,
Elijah Newren <newren@gmail.com>,
Dmitry Goncharov <dgoncharov@users.sf.net>
Subject: [PATCH 1/2] t6423: add a testcase causing a failed assertion in process_renames
Date: Thu, 06 Mar 2025 15:30:26 +0000 [thread overview]
Message-ID: <69da363cab9127cbe4fe6843c49c1a41ba9d4521.1741275027.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.1873.git.1741275027.gitgitgadget@gmail.com>
From: Dmitry Goncharov <dgoncharov@users.sf.net>
If one side of history renames a directory A/ -> B/, and the other side
of history adds new files to A/, then directory rename detection notices
and moves or suggests moving those new files to B/. A similar thing is
done for paths renamed into A/, causing them to be transitively renamed
into B/. But, if the file originally came from B/, then this can end up
causing a file to be renamed back to itself. merge-ort crashes under
this special case, due to a slightly overzealous assertion:
git: merge-ort.c:3051: process_renames: Assertion `source_deleted || oldinfo->filemask & old_sidemask' failed.
Aborted (core dumped)
Add a testcase demonstrating this.
Signed-off-by: Dmitry Goncharov <dgoncharov@users.sf.net>
[en: Instead of adding a new testsuite, place it near similar tests in
t6423, adjusting to match the style of those tests. Tweak the commit
message to not repeat the entire testcase, but just describe the bug.
Also update the line number in the error message.]
Signed-off-by: Elijah Newren <newren@gmail.com>
---
t/t6423-merge-rename-directories.sh | 41 +++++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/t/t6423-merge-rename-directories.sh b/t/t6423-merge-rename-directories.sh
index 88d1cf2cde9..259ee9628e4 100755
--- a/t/t6423-merge-rename-directories.sh
+++ b/t/t6423-merge-rename-directories.sh
@@ -5360,6 +5360,47 @@ test_expect_merge_algorithm failure success '12m: Change parent of renamed-dir t
)
'
+test_setup_12n () {
+ git init 12n &&
+ (
+ cd 12n &&
+
+ mkdir tools &&
+ echo hello >tools/hello &&
+ git add tools/hello &&
+ git commit -m "O" &&
+
+ git branch O &&
+ git branch A &&
+ git branch B &&
+
+ git switch A &&
+ echo world >world &&
+ git add world &&
+ git commit -q world -m 'Add world' &&
+
+ git mv world tools/world &&
+ git commit -m "Move world into tools/" &&
+
+ git switch B &&
+ git mv tools/hello hello &&
+ git commit -m "Move hello from tools/ to toplevel"
+ )
+}
+
+test_expect_failure '12n: Directory rename transitively makes rename back to self' '
+ test_setup_12n &&
+ (
+ cd 12n &&
+
+ git checkout -q B^0 &&
+
+ test_must_fail git cherry-pick A^0 >out &&
+ grep "CONFLICT (file location).*should perhaps be moved" out
+ )
+'
+
+
###########################################################################
# SECTION 13: Checking informational and conflict messages
#
--
gitgitgadget
next prev parent reply other threads:[~2025-03-06 15:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-06 15:30 [PATCH 0/2] merge-ort: fix a crash in process_renames for a file transitively renamed to itself Elijah Newren via GitGitGadget
2025-03-06 15:30 ` Dmitry Goncharov via GitGitGadget [this message]
2025-03-06 15:30 ` [PATCH 2/2] merge-ort: fix slightly overzealous assertion for rename-to-self Elijah Newren via GitGitGadget
2025-03-12 22:00 ` Taylor Blau
2025-03-12 22:36 ` Elijah Newren
2025-03-12 23:18 ` Junio C Hamano
2025-03-13 6:22 ` Elijah Newren
2025-03-13 16:55 ` Junio C Hamano
2025-03-13 17:15 ` Elijah Newren
2025-03-13 18:34 ` Junio C Hamano
2025-03-14 0:24 ` Elijah Newren
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=69da363cab9127cbe4fe6843c49c1a41ba9d4521.1741275027.git.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=dgoncharov@users.sf.net \
--cc=git@vger.kernel.org \
--cc=newren@gmail.com \
/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).