From: Hugo Sales <hugo@hsal.es>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Derrick Stolee <derrickstolee@github.com>,
Shaoxuan Yuan <shaoxuan.yuan02@gmail.com>
Subject: Re: [PATCH 0/3] Add `-p' option to `git-mv', inspired by `mkdir'
Date: Wed, 11 Oct 2023 13:33:19 +0100 (WEST) [thread overview]
Message-ID: <1384513657.119681.1697027599941@office.mailbox.org> (raw)
In-Reply-To: <xmqq1qe3wbt1.fsf@gitster.g>
> 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.
> 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
next prev parent reply other threads:[~2023-10-11 12:33 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-09 23:34 [PATCH 0/3] Add `-p' option to `git-mv', inspired by `mkdir' Hugo Sales
2023-10-09 23:34 ` [PATCH 1/3] mv: Add -p option to create parent directories Hugo Sales
2023-10-09 23:34 ` [PATCH 2/3] mv: Add tests for new -p flag Hugo Sales
2023-10-09 23:34 ` [PATCH 3/3] mv: Add documentation for new `-p' flag Hugo Sales
2023-10-10 0:39 ` [PATCH 0/3] Add `-p' option to `git-mv', inspired by `mkdir' Junio C Hamano
2023-10-10 0:59 ` Junio C Hamano
2023-10-11 12:33 ` Hugo Sales [this message]
2023-10-31 4:30 ` Junio C Hamano
2023-10-31 4:54 ` Dragan Simic
2023-10-31 5:58 ` Junio C Hamano
2023-10-31 6:38 ` Dragan Simic
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=1384513657.119681.1697027599941@office.mailbox.org \
--to=hugo@hsal.es \
--cc=derrickstolee@github.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=shaoxuan.yuan02@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).