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

Re: [PATCH 6/6] completion: clarify ls-tree, archive, show completion

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Jun 7, 2013, 18:45 UTC
Message-ID
<20130607184527.GB25731@goldbirke>
In-Reply-To
<CALkWK0mbVgJHRoNXNkc6n7==-H+caNqvzrzUwspS_Eq2sMfJbg@mail.gmail.com>
On Fri, Jun 07, 2013 at 10:51:53PM +0530, Ramkumar Ramachandra wrote:
Show 7 quoted lines
> SZEDER Gábor wrote:
> > Well, people out there might have completion scriplets for their
> > aliases or custom git commands which use __git_complete_file().
> > Removing this function would break those scripts.
> 
> What is the advantage of using __git_complete_file() over
> __git_complete_revlist_file()?

That it doesn't imply that the command takes refs in the form of ref1..ref2.

> Isn't it just a misleading alias?

No. It's an implementation detail that __git_complete_file() became an alias to __git_complete_revlist_file() to avoid unnecessary code duplication.

And it was a concious decision to keep __git_complete_file() (and __git_complete_revlist()) around in order not to break completion scriplets for users' alieses and custom git commands which might call it.

Show 8 quoted lines
> > Arguably the name of __git_complete_file() could describe better what
> > the function does, or what it did, i.e. it used to provide completion
> > for the master:Doc<TAB> notation.  But that's only the name.  Since
> > both git ls-tree and git archive understand this notation, calling the
> > helper for master:Doc<TAB> in their completion functions is not
> > misleading at all.
> 
> But __git_complete_revlist_file() provides all this and more, no?

Indeed, and this "more" is exactly why it is misleading to call __git_complete_revlist_file() directly for git ls-tree and git archive.

Show 9 quoted lines
> > Now, __git_complete_revlist_file() provides completion both for this
> > master:Doc<TAB> notation and for revision ranges, i.e. for
> > master..n<TAB> and master...n<TAB>.  However, since neither git
> > ls-tree nor git archive accept revision ranges, calling
> > __git_complete_revlist_file() in their completion function would be
> > misleading.
> 
> Yeah, they accept tree-ish'es.  Isn't __git_complete_file() still a
> horrible name?
We can't go back in time to correct it, unfortunately.
Show 5 quoted lines
> If anything, we
> should write a new __git_complete_treeish() function that does what
> __git_complete_revlist_file() does, except that it doesn't complete
> revision ranges, right?  Frankly, I don't know if it's worth the
> additional trouble

I agree that it isn't worth it, and that is exactly why __git_complete_revlist() and __git_complete_file() were unified in __git_complete_revlist_file().

>   $ git log HEAD:Doc<TAB>
> 
> Note how log doesn't even error out.
But note how git log master..HEAD:Documentation/ errors out.
Show 6 quoted lines
> > git show is special, as it understands both the master:Doc<TAB>
> > notation and revision ranges, and even the combination of the two, so
> > calling __git_complete_revlist_file() there would indeed be better.
> 
> It just accepts any revspec with pathspec filtering, like many many
> other commands.
Which many many other commands do accept ref1..ref2:file?
Gábor
Previous: Junio C HamanoNext: Junio C Hamano
Message 32 of 33 in “Minor prompt, completion cleanups”
  1. 0/6 Minor prompt, completion cleanupsRamkumar Ramachandra, Jun 2, 2013
  2. 1/6 prompt: don't scream continuation stateRamkumar Ramachandra, Jun 2, 2013
  3. Thomas RastJun 3, 2013
  4. Ramkumar RamachandraJun 3, 2013
  5. Jeff KingJun 3, 2013
  6. Ramkumar RamachandraJun 4, 2013
  7. Jeff KingJun 4, 2013
  8. Junio C HamanoJun 4, 2013
  9. Junio C HamanoJun 3, 2013
  10. 2/6 completion: add common options for rev-parseRamkumar Ramachandra, Jun 2, 2013
  11. Ramkumar RamachandraJun 7, 2013
  12. 3/6 completion: add common options for blameRamkumar Ramachandra, Jun 2, 2013
  13. Thomas RastJun 3, 2013
  14. Ramkumar RamachandraJun 3, 2013
  15. SZEDER GáborJun 3, 2013
  16. Junio C HamanoJun 3, 2013
  17. Peter KreftingJun 6, 2013
  18. Junio C HamanoJun 3, 2013
  19. 4/6 completion: correct completion for format-patchRamkumar Ramachandra, Jun 2, 2013
  20. Felipe ContrerasJun 2, 2013
  21. Ramkumar RamachandraJun 2, 2013
  22. 5/6 completion: clarify difftool completionRamkumar Ramachandra, Jun 2, 2013
  23. Junio C HamanoJun 3, 2013
  24. 6/6 completion: clarify ls-tree, archive, show completionRamkumar Ramachandra, Jun 2, 2013
  25. Junio C HamanoJun 3, 2013
  26. Ramkumar RamachandraJun 4, 2013
  27. Junio C HamanoJun 4, 2013
  28. Junio C HamanoJun 3, 2013
  29. SZEDER GáborJun 3, 2013
  30. Ramkumar RamachandraJun 7, 2013
  31. Junio C HamanoJun 7, 2013
  32. SZEDER GáborJun 7, 2013
  33. Junio C HamanoJun 9, 2013

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.