From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Kristoffer Haugsbakk <code@khaugsbakk.name>,
Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH 1/2] builtin/mv: bail out when trying to move child and its parent
Date: Fri, 2 May 2025 10:07:38 +0200 [thread overview]
Message-ID: <aBR9Slq7_F9PRq0W@pks.im> (raw)
In-Reply-To: <xmqqmsbxz3wp.fsf@gitster.g>
On Wed, Apr 30, 2025 at 03:21:42PM -0700, Junio C Hamano wrote:
> 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
next prev parent reply other threads:[~2025-05-02 8:07 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-30 12:44 [PATCH 0/2] builtin/mv: bail out when trying to move child and its parent Patrick Steinhardt
2025-04-30 12:44 ` [PATCH 1/2] " Patrick Steinhardt
2025-04-30 22:21 ` Junio C Hamano
2025-05-02 8:07 ` Patrick Steinhardt [this message]
2025-04-30 12:44 ` [PATCH 2/2] builtin/mv: convert assert(3p) into `BUG()` Patrick Steinhardt
2025-04-30 18:45 ` Junio C Hamano
2025-04-30 23:10 ` Junio C Hamano
2025-05-02 8:06 ` Patrick Steinhardt
2025-05-02 9:44 ` Johannes Schindelin
2025-05-02 16:53 ` Junio C Hamano
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=aBR9Slq7_F9PRq0W@pks.im \
--to=ps@pks.im \
--cc=Johannes.Schindelin@gmx.de \
--cc=code@khaugsbakk.name \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.