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

Re: [PATCH 0/3] Add `-p' option to `git-mv', inspired by `mkdir'

From
HSHugo Sales <hugo@hsal.es>
Date
Oct 11, 2023, 12:33 UTC
Message-ID
<1384513657.119681.1697027599941@office.mailbox.org>
In-Reply-To
<xmqq1qe3wbt1.fsf@gitster.g>
Show 16 quoted lines
> On 10/10/2023 12:39 AM GMT Junio C Hamano <gitster@pobox.com> wrote:
> 
> Is there a reason why somebody benefits by us retaining the current
> behaviour, where
> 
>     $ git mv file no/such/dir/yet/file
> 
> fails with "No such file or directory", and they are forced to say
> either
> 
>     $ mkdir -p no/such/dir/yet
>     $ git mv file no/such/dir/yet/file
> 
> or
> 
>     $ git mv -p file no/such/dir/yet/file
Somewhat, as it could be a typo, so if you actually want to create a new folder, you have to be explicit. I wouldn't be opposed to removing the need for the flag, but if we did, I think we should warn the user that a new directory was created.
Show 16 quoted lines
> Imagine there is no "no" directory (so nothing under it
> exists), and you did this (you do have a regular file "file").
> 
>     $ git mv [-p] file no/such/dir/yet
> 
> What should happen?  Would we do the equivalent of
> 
>     $ mkdir -p no/such/dir && git mv file no/such/dir/yet
> 
> or are we doing
> 
>     $ mkdir -p no/such/dir/yet && git mv file no/such/dir/yet/file
> 
> Both are plausible, and "mkdir -p" does not have such a nasty
> ambiguity.  That is what makes me unsure about the new feature
> (again, either with required "-p" or with implied "-p").
I think the ambiguity is resolved by the inclusion of lack thereof of a trailing `/`. This is what the implementation already does, too, before this patch. So
     $ git mv [-p] file no/such/dir/yet
would be the same as
     $ mkdir -p no/such/dir && git mv file no/such/dir/yet
and
     $ git mv [-p] file no/such/dir/yet/
would be the same as
     $ mkdir -p no/such/dir/yet && git mv file no/such/dir/yet/
Moving `file` to `no/such/dir/yet/file`

Thanks for the feedback, Hugo

P.S. Apologies for the duplicated email, Junio, I did a Reply instead of a Reply All
Previous: Junio C HamanoNext: Junio C Hamano
Message 7 of 11 in “Add `-p' option to `git-mv', inspired by `mkdir'”
  1. 0/3 Add `-p' option to `git-mv', inspired by `mkdir'Hugo Sales, Oct 9, 2023
  2. 2/3 mv: Add tests for new -p flagHugo Sales, Oct 9, 2023
  3. 3/3 mv: Add documentation for new `-p' flagHugo Sales, Oct 9, 2023
  4. 1/3 mv: Add -p option to create parent directoriesHugo Sales, Oct 9, 2023
  5. Junio C HamanoOct 10, 2023
  6. Junio C HamanoOct 10, 2023
  7. Hugo SalesOct 11, 2023
  8. Junio C HamanoOct 31, 2023
  9. Dragan SimicOct 31, 2023
  10. Junio C HamanoOct 31, 2023
  11. Dragan SimicOct 31, 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.