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

Re: [PATCH] fix `git mv existing-dir non-existing-dir`*

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 8, 2023, 21:53 UTC
Message-ID
<xmqqmsz16w1q.fsf@gitster.g>
In-Reply-To
<20230808184054.cjhiboifschkwuoz@tb-raspi4>
Torsten Bögershausen <tboegi@web.de> writes:
Show 16 quoted lines
> On Tue, Aug 08, 2023 at 10:36:54AM -0700, Junio C Hamano wrote:
>> "Sebastian Thiel via GitGitGadget" <gitgitgadget@gmail.com> writes:
>>
>> > From: Sebastian Thiel <sebastian.thiel@icloud.com>
>> >
>
> The patch makes sense to me, Junio's comments included.
>
>> Shouldn't it do something similar to
>>
>>     $ mv D1 D2
>
> Couldn't resist to test it ;-)
>
> The result would be
>  renamed: D1/file1 -> D2/D1/file1

Sure. The lstat() in question is about the case where a different D2/D1 already exists, either as a file (which will definitely break as we do not and should not do unlink-and-then-mkdir) or as a directory (which may be OK in some cases to get a union of the contents in the original D1 and D2/D1, but in general not a good idea).

And in the latter case, i.e. when D2/D1 exists as a directory, we should not say "cannot move directory over file". So, the check that does not care what the dest_dir's type is fine. but the error message is wrong.

    "cannot move directory over file, source=D1, destination=D1/D2"

is the message we would get in such a case. We probably just should say

    "destination already exists, source=D1, destination=D1/D2"
or something like that.
Previous: Torsten BögershausenNext: Junio C Hamano
Message 5 of 7 in “fix `git mv existing-dir non-existing-dir`*”
  1. fix `git mv existing-dir non-existing-dir`*Sebastian Thiel via GitGitGadget, Aug 8, 2023
  2. Junio C HamanoAug 8, 2023
  3. Junio C HamanoAug 8, 2023
  4. Torsten BögershausenAug 8, 2023
  5. Junio C HamanoAug 8, 2023
  6. mv: fix error for moving directory to anotherJunio C Hamano, Aug 12, 2023
  7. fix `git mv existing-dir non-existing-dir` in some environments.Sebastian Thiel via GitGitGadget, Aug 9, 2023

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.