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

Re: [PATCH v2] gitcli: tweak "man gitcli" for clarity

From
Jeff King <peff@peff.net>
Date
Nov 24, 2017, 18:12 UTC
Message-ID
<20171124181254.GC29190@sigill>
In-Reply-To
<20171123205503.GE16418@alpha.vpn.ikke.info>
On Thu, Nov 23, 2017 at 09:55:03PM +0100, Kevin Daudt wrote:
Show 15 quoted lines
> > > >   Without a disambiguating `--`, Git makes a reasonable guess. If it
> > > >   cannot guess (because your request is ambiguous), then it will error
> > > >   out.
> [...]
> > > 1) even without the "--", git can generally parse the command and do
> > > the right thing (or do a *valid* thing, given its heuristics)
> > > 
> > > 2) occasionally, without the "--", the command is really and truly
> > > ambiguous, at which point git will fail and tell you to disambiguate
> [...]
> 
> Just for completeness, as it is somewhat covered by point 1 already, but
> there are cases where there is no real ambiguity but you are required to
> add '--' to tell git that it should not look for the file in the working
> tree:

Right, I was focused on what the sentence _currently_ said, and didn't think about other cases. The "cannot guess" case is not just due to ambiguity, but may be due to other heuristics.

I _think_ the only one is the "does it exist in the working tree" rule you found, but I'm not sure we'd want to commit ourselves to never changing that.

You could make my suggestion correct by putting "e.g.," or "for example" at the front of the parentheses. ;)

There is an open question of how carefully we want to document it, but I think the strategy so far has been:

 - if you want to be careful, use "--"
 - if you don't, git will use black magic to guess, but that magic is
   subject to change, so don't rely on it

I don't mind documenting the current magic as long as the "don't rely on it" part is made clear.

Show 10 quoted lines
>   $ git show abc123 deleted_file.txt
>   fatal: ambiguous argument 'deleted_file.txt':
>   unknown revision or path not in the working tree.
>   Use '--' to separate paths from revisions, like this:
>   'git <command> [<revision>...] -- [<file>...]'
> 
> There might be good reasons why this is, but I don't consider this to be
> actually ambiguous: there is no branch called 'deleted_file.txt' and git
> could know that the files exists in the mentioned commit, so it should
> be pretty clear what is meant.

For that command, yes. But when the command is "git log", do we really want to dig through all of history to see if anybody ever mentions "deleted_file"?

I'm not sure if we want to get into having different rules for different contexts. Not to mention that this really mixes up the layers; you cannot know what the whole command line means until you decide what abc123 means and examine it, which may in turn be influenced by other options. E.g., given:

  git log --no-merges A..B deleted_file.txt

we have to actually do the no-merges log of A..B to see if deleted_file.txt is in there.

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 18 of 19 in “gitcli: tweak "man gitcli" for clarity”
  1. gitcli: tweak "man gitcli" for clarityRobert P. J. Day, Nov 21, 2017
  2. Kevin DaudtNov 21, 2017
  3. Robert P. J. DayNov 21, 2017
  4. Kevin DaudtNov 21, 2017
  5. Robert P. J. DayNov 21, 2017
  6. Robert P. J. DayNov 22, 2017
  7. Junio C HamanoNov 22, 2017
  8. Robert P. J. DayNov 22, 2017
  9. Kevin DaudtNov 22, 2017
  10. Robert P. J. DayNov 22, 2017
  11. Jeff KingNov 23, 2017
  12. Junio C HamanoNov 23, 2017
  13. Robert P. J. DayNov 23, 2017
  14. Jeff KingNov 23, 2017
  15. Kevin DaudtNov 23, 2017
  16. Junio C HamanoNov 24, 2017
  17. Jeff KingNov 24, 2017
  18. Jeff KingNov 24, 2017
  19. Junio C HamanoNov 25, 2017

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.