Re: [PATCH 1/2] builtin/mv: bail out when trying to move child and its parent
- From
Patrick Steinhardt <ps@pks.im>
- Date
- May 2, 2025, 08:07 UTC
- Message-ID
- <aBR9Slq7_F9PRq0W@pks.im>
- In-Reply-To
- <xmqqmsbxz3wp.fsf@gitster.g>
On Wed, Apr 30, 2025 at 03:21:42PM -0700, Junio C Hamano wrote:
Show 29 quoted lines
> Patrick Steinhardt <ps@pks.im> writes:
> > - test_must_fail git mv a/a.txt a b &&
> > - git status --porcelain >actual &&
> > - grep "^A[ ]*a/a.txt$" actual
> > + cat >expect <<-EOF &&
> > + fatal: cannot move both ${SQ}a/a.txt${SQ} and its parent directory ${SQ}a${SQ}
> > + EOF
> > + test_must_fail git mv a/a.txt a b 2>err &&
> > + test_cmp expect err
> > +'
>
> Shouldn't we make sure that after failing "git mv" the paths and the
> index entries stay as expected?
>
> > +test_expect_success 'moving nested directory and its parent directory at the same time fails' '
> > + test_when_finished git reset --hard HEAD &&
> > + git reset --hard HEAD &&
> > + mkdir -p a/b/c &&
> > + >a/b/c/file.txt &&
> > + git add a &&
> > + mkdir target &&
> > + cat >expect <<-EOF &&
> > + fatal: cannot move both ${SQ}a/b/c${SQ} and its parent directory ${SQ}a${SQ}
> > + EOF
> > + test_must_fail git mv a/b/c a target 2>err &&
> > + test_cmp expect err
> > '
>
> Ditto.This might've been a good idea, but I see that the series has already been merged to `next`. So I'll refrain from improving the tests.
Thanks!
Patrick