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

Re: [PATCH] bash: support user-supplied completion scripts for user's git commands

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Feb 26, 2010, 15:27 UTC
Message-ID
<20100226152710.GA17460@neumann>
In-Reply-To
<7viqakireb.fsf@alter.siamese.dyndns.org>
Hi,
On Fri, Jan 29, 2010 at 12:32:12PM -0800, Junio C Hamano wrote:
> Admittedly, we have already taken over _git_foo (and "_git") namespace,
> and anybody who uses bash with the completion support cannot write their
> own shell function with these names for purposes that are unrelated to
> completion,

Actually, the "_" namespace is taken over by bash completion in general, so writing shell functions starting with "_" is probably not a good idea anyway. E.g. to see all non-completion-related shell functions you can do a "declare -F |grep -v ' _'", but if you name shell functions not related to completion as _git_foo(), then this will no longer work.

Show 9 quoted lines
> so in that sense, the patch is not introducing a new problem,
> but making it a documented interface and casting it in stone will make the
> namespace contamination issue harder to rectify later.
> 
> So if we were to go in the direction as the patch proposes (which I think
> is a good idea), we might want to rename them to __git_completion_foo or
> something that is less likely to collide with whatever names users might
> want to use. It is my understanding that the only published interface so
> far is __git_ps1.

I would say that __git_ps1() is the only interface that is advertised as being public. If someone is unsatisfied with the completion script, because he wanted completion for a custom git command or for a frequently used plumbing command, then I bet he just reused existing functions, e.g. when he needed refs, he just used __git_refs(), or when he needed git log's options, he used _git_log(). I did that, probably others too. If we were to rename completion functions, these people's setup will break (although they will likely get merge conflicts caused by this patch anyway). On the other hand: should we really care that much about such users, who use non-pulic interfaces from contrib/ ?

Having said all that, I don't really care either way. If you or Shawn would prefer to have the completion functions renamed, I will do a s/this/that/ preparation patch for the series. BTW, Mercurial's completion script uses _hg_cmd_foo() for hg commands and _hg_ext_bar() for extensions, so we might as well be a bit consistent, and call our completion functions _git_cmd_foo().

Best, Gábor

Previous: Junio C HamanoNext: Junio C Hamano
Message 20 of 25 in “Custom git completion”
  1. David Rhodes ClymerJan 29, 2010
  2. Shawn O. PearceJan 29, 2010
  3. Junio C HamanoJan 29, 2010
  4. Shawn O. PearceJan 29, 2010
  5. Junio C HamanoJan 29, 2010
  6. bash: support user-supplied completion scripts for user's git commandsSZEDER Gábor, Jan 29, 2010
  7. Shawn O. PearceJan 29, 2010
  8. SZEDER GáborJan 29, 2010
  9. Shawn O. PearceJan 29, 2010
  10. SZEDER GáborJan 31, 2010
  11. 0/4 bash: support user-supplied completion scripts for custom git commands and aliasesSZEDER Gábor, Feb 23, 2010
  12. 1/4 bash: improve aliased command recognitionSZEDER Gábor, Feb 23, 2010
  13. Junio C HamanoFeb 23, 2010
  14. SZEDER GáborFeb 24, 2010
  15. Junio C HamanoFeb 24, 2010
  16. 2/4 bash: support user-supplied completion scripts for user's git commandsSZEDER Gábor, Feb 23, 2010
  17. 3/4 bash: support user-supplied completion scripts for aliasesSZEDER Gábor, Feb 23, 2010
  18. 4/4 bash: completion for gitk aliasesSZEDER Gábor, Feb 23, 2010
  19. Junio C HamanoJan 29, 2010
  20. SZEDER GáborFeb 26, 2010
  21. Junio C HamanoFeb 26, 2010
  22. Shawn O. PearceFeb 26, 2010
  23. David Rhodes ClymerJan 30, 2010
  24. David Rhodes ClymerJan 30, 2010
  25. David Rhodes ClymerJan 30, 2010

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.