]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/mv: bail out when trying to move child and its parent
authorPatrick Steinhardt <ps@pks.im>
Wed, 30 Apr 2025 12:44:57 +0000 (14:44 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 30 Apr 2025 22:05:15 +0000 (15:05 -0700)
commit8583c9dcbc7d362250c0310e4cee771ec5003327
tree0ea1c4f289c51ab0d6a5368656d09fb64768f040
parentf93ff170b93a1782659637824b25923245ac9dd1
builtin/mv: bail out when trying to move child and its parent

We have a known issue in git-mv(1) where moving both a child and any of
its parents causes an assert to trigger because the child cannot be
found anymore in the index. We have added a test for this in commit
0fcd473fdd3 (t7001: add failure test which triggers assertion,
2024-10-22) without addressing the issue, which is why the test itself
is marked as `test_expect_failure`.

The behaviour of that test relies on a call to assert(3p) though, which
may or may not be compiled into the resulting binary depending on
whether or not we pass `-DNDEBUG`. When these asserts are compiled into
Git this may cause our CI to hang on Windows though, because asserts may
cause a modal window to be shown.

While we could work around the issue by converting this into a call to
`BUG()`, let's rather address the root cause of the issue by bailing out
in case we see that both a child and any of its parents are being moved
in the same command.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/mv.c
t/t7001-mv.sh