From: Junio C Hamano <gitster@pobox.com>
To: "Kristoffer Haugsbakk" <code@khaugsbakk.name>
Cc: git@vger.kernel.org
Subject: Re: [BUG] mv: can trigger assertion failure with three parameters (builtin/mv.c:481)
Date: Fri, 05 Jan 2024 10:52:35 -0800 [thread overview]
Message-ID: <xmqqil47obnw.fsf@gitster.g> (raw)
In-Reply-To: <d1f739fe-b28e-451f-9e01-3d2e24a0fe0d@app.fastmail.com> (Kristoffer Haugsbakk's message of "Fri, 05 Jan 2024 18:41:35 +0100")
"Kristoffer Haugsbakk" <code@khaugsbakk.name> writes:
> You can trigger an assertion by giving these arguments to `git mv`:
>
> <dir>/file <dir> <other dir>
> ...
>> What did you expect to happen? (Expected behavior)
>
> A normal error message if the command is nonsensical (I don’t know; that’s
> not the point). Also `.git/index.lock` to be cleaned up.
Good find.
Not just that, but when the command fails in the middle like this,
it leaves the working tree in a half-updated state, i.e.
> ./bin-wrappers/git -C $dir mv $dir/a/a.txt $dir/a $dir/b
will first move a/a.txt to b/a.txt, then try to move a (actually,
all contents of it, including a/a.txt) to b/a and finds that "the
command is nonsensical" and aborts, and by that time, there is no
a/a.txt (i.e. the working tree has been modified). The failure
should be made atomic, just like "git switch" to another branch may
stop _without_ touching anything in the working tree when it may
have to fail (e.g., due to a file being dirty).
Thanks for reporting, Kristoffer.
Any takers?
$ git shortlog --since=3.years -s -n -e --no-merges v2.43.0 builtin/mv.c
15 Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
10 Elijah Newren <newren@gmail.com>
5 Ævar Arnfjörð Bjarmason <avarab@gmail.com>
2 Junio C Hamano <gitster@pobox.com>
1 Andrzej Hunt <ajrhunt@google.com>
1 Calvin Wan <calvinwan@google.com>
1 Derrick Stolee <stolee@gmail.com>
1 Sebastian Thiel <sebastian.thiel@icloud.com>
1 Torsten Bögershausen <tboegi@web.de>
next prev parent reply other threads:[~2024-01-05 18:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-05 17:41 [BUG] mv: can trigger assertion failure with three parameters (builtin/mv.c:481) Kristoffer Haugsbakk
2024-01-05 18:52 ` Junio C Hamano [this message]
2024-01-05 19:06 ` Dragan Simic
2024-02-18 12:42 ` Kristoffer Haugsbakk
2024-10-20 22:14 ` [PATCH v2] t7001: add failure test which triggers assertion kristofferhaugsbakk
2024-10-21 21:21 ` Taylor Blau
2024-10-21 21:25 ` Kristoffer Haugsbakk
2024-10-21 21:29 ` Taylor Blau
2024-10-22 21:14 ` [PATCH v3] " kristofferhaugsbakk
2024-10-23 20:36 ` Taylor Blau
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=xmqqil47obnw.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=code@khaugsbakk.name \
--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).