git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: Junio C Hamano
Message 10 of 10 in “builtin/mv: bail out when trying to move child and its parent”
  1. 0/2 builtin/mv: bail out when trying to move child and its parentPatrick Steinhardt, Apr 30, 2025
  2. 2/2 builtin/mv: convert assert(3p) into `BUG()`Patrick Steinhardt, Apr 30, 2025
  3. Junio C HamanoApr 30, 2025
  4. Junio C HamanoApr 30, 2025
  5. Patrick SteinhardtMay 2, 2025
  6. Johannes SchindelinMay 2, 2025
  7. Junio C HamanoMay 2, 2025
  8. 1/2 builtin/mv: bail out when trying to move child and its parentPatrick Steinhardt, Apr 30, 2025
  9. Junio C HamanoApr 30, 2025
  10. Patrick SteinhardtMay 2, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.