Re: [BUG] mv: can trigger assertion failure with three parameters (builtin/mv.c:481)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Kristoffer Haugsbakk" <code@xxxxxxxxxxxxxxx> 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@xxxxxxxxx>
    10	Elijah Newren <newren@xxxxxxxxx>
     5	Ævar Arnfjörð Bjarmason <avarab@xxxxxxxxx>
     2	Junio C Hamano <gitster@xxxxxxxxx>
     1	Andrzej Hunt <ajrhunt@xxxxxxxxxx>
     1	Calvin Wan <calvinwan@xxxxxxxxxx>
     1	Derrick Stolee <stolee@xxxxxxxxx>
     1	Sebastian Thiel <sebastian.thiel@xxxxxxxxxx>
     1	Torsten Bögershausen <tboegi@xxxxxx>





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux