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

Re: Re: [PATCH 1/3] checkout.c: add strict usage of -- before file_path

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
May 13, 2018, 20:18 UTC
Message-ID
<20180513201810.6440-1-szeder.dev@gmail.com>
In-Reply-To
<775fe020-be92-f65c-5a67-e83e6bf4777f@gmail.com>
Show 17 quoted lines
> On 13/05/2018 00:03, Duy Nguyen wrote:
> 
> > On Sun, May 13, 2018 at 4:23 AM, Dannier Castro L <danniercl@gmail.com> wrote:
> >> 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.
> > I would like an option to revert back to current behavior. I'm not a
> > new user. I know what I'm doing. Please don't make me type more.
> >
> > And '--" is not completely useless. If you have <file> and <branch>
> > with the same name, you have to give "--" to to tell git what the
> > first argument means.
> 
> Sure Duy, you're right, probably "completely useless" is not the correct
> definition,
No, "completely useless" is just plain wrong.
> even according with the code I didn't find another useful
> case that is not file and branch with the same name.

The optional disambiguating doubledash is the standard way to erm, well, to disambiguate whatever there is to disambiguate. Not only refs and filenames, but also e.g. options and filenames:

  $ git checkout --option-looking-file
  error: unknown option `option-looking-file'
  usage: git checkout [<options>] <branch>
  <...>
  $ git checkout -- --option-looking-file
  error: pathspec '--option-looking-file' did not match any file(s) known to git.

Note that this is not at all specific to Git, many other programs support the optional disambiguating doubledash as well:

  $ touch --option-looking-file
  touch: unrecognized option '--option-looking-file'
  Try 'touch --help' for more information.
  $ touch -- --option-looking-file
  $ ls --option-looking-file
  ls: unrecognized option '--option-looking-file'
  Try 'ls --help' for more information.
  $ ls -- --option-looking-file
  --option-looking-file
Please do not make it mandatory.
Previous: Dannier Castro LNext: Philip Oakley
Message 6 of 11 in “checkout.c: add strict usage of -- before file_path”
  1. 1/3 checkout.c: add strict usage of -- before file_pathDannier Castro L, May 13, 2018
  2. 2/3 test: update tests for strict usage of -- checkoutDannier Castro L, May 13, 2018
  3. 3/3 doc: update doc for strict usage of -- checkoutDannier Castro L, May 13, 2018
  4. Duy NguyenMay 13, 2018
  5. Dannier Castro LMay 13, 2018
  6. SZEDER GáborMay 13, 2018
  7. Philip OakleyMay 13, 2018
  8. Junio C HamanoMay 14, 2018
  9. Kevin DaudtMay 13, 2018
  10. Duy NguyenMay 14, 2018
  11. Duy NguyenMay 14, 2018

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.