From: Kevin Daudt <me@ikke.info>
To: Dannier Castro L <danniercl@gmail.com>
Cc: git@vger.kernel.org, gitster@pobox.com, Matthieu.Moy@imag.fr,
jrnieder@gmail.com, bmwill@google.com
Subject: Re: [PATCH 1/3] checkout.c: add strict usage of -- before file_path
Date: Sun, 13 May 2018 23:02:33 +0200 [thread overview]
Message-ID: <20180513210233.GA18892@alpha> (raw)
In-Reply-To: <1526178214-30956-1-git-send-email-danniercl@gmail.com>
On Sat, May 12, 2018 at 08:23:32PM -0600, Dannier Castro L wrote:
> Currently, <checkout> is a complex command able to handle both
> branches and files without any distintion other than their names,
> taking into account that depending on the type (branch or file),
> the functionality is completely different, the easier example:
>
> $ git checkout <branch> # Switch from current branch to <branch>.
> $ git checkout <file> # Restore <file> from HEAD, discarding
> # changes if it's necessary.
> $ git checkout -- <file> # The same as the last one, only with an
> # useless '--'.
>
> For GIT new users, this complicated versatility of <checkout> could
> be very confused, also considering that actually the flag '--' is
> completely useless (added or not, there is not any difference for
> this command), when the same program messages promote the use of
> this flag.
>
> Regarding the <checkout>'s power to overwrite any file, discarding
> changes if they exist without some way of recovering them, the
> solution propuses that the usage of '--' is strict before to
> specify the file(s) path(s) for any <checkout> command (including
> all types of flags), as a "defense barrier" to make sure about
> user's knowledge and intension running <checkout>.
>
> The solution consists in detect '--' into command args, allowing
> the discard of changes and considering the following names as
> file paths, otherwise, they are branch names.
>
> Signed-off-by: Dannier Castro L <danniercl@gmail.com>
One data point indicating this is giving issues is that today on IRC a
user was confused why `git checkout pt` did not show any message and did
not checkout a remote branch called 'pt' as they expected. It turned out
they also had a local file/dir called 'pt', which caused git to checkout
that file/dir rather than creating a local branch based on the remote
branch.
Kevin
next prev parent reply other threads:[~2018-05-13 21:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-13 2:23 [PATCH 1/3] checkout.c: add strict usage of -- before file_path Dannier Castro L
2018-05-13 2:23 ` [PATCH 2/3] test: update tests for strict usage of -- checkout Dannier Castro L
2018-05-13 2:23 ` [PATCH 3/3] doc: update doc " Dannier Castro L
2018-05-13 6:03 ` [PATCH 1/3] checkout.c: add strict usage of -- before file_path Duy Nguyen
2018-05-13 19:11 ` Dannier Castro L
2018-05-13 20:18 ` SZEDER Gábor
2018-05-13 23:06 ` Philip Oakley
2018-05-14 1:51 ` Junio C Hamano
2018-05-13 21:02 ` Kevin Daudt [this message]
2018-05-14 14:52 ` Duy Nguyen
2018-05-14 15:43 ` Duy Nguyen
[not found] <9e3a36eea5d34dc2941560b96046dc27@BPMBX2013-01.univ-lyon1.fr>
2018-05-13 16:52 ` Matthieu Moy
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=20180513210233.GA18892@alpha \
--to=me@ikke.info \
--cc=Matthieu.Moy@imag.fr \
--cc=bmwill@google.com \
--cc=danniercl@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jrnieder@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 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.