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
Junio C Hamano <gitster@pobox.com>
Date
Feb 26, 2010, 20:04 UTC
Message-ID
<7vmxyvsqzn.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20100226152710.GA17460@neumann>
SZEDER Gábor <szeder@ira.uka.de> writes:
>> 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.

I won't quote the first paragraph where you are repeating what I said, while sounding as if you were disagreeing with me.

Show 11 quoted lines
>> So if we were to ...
>> ... 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 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/ ?

I see we are in agreement in the first half of your paragraph; my answer to the question in the latter half is:

 - we shouldn't care about people who already used unpublished interface
   in contrib/ so far; _but_
 - because we will be advertising it as a way to override and enhance
   completion to define your own shell functions, the naming _will_ become
   part of published interface---what we decide _now_ will matter.

That is why I wanted people to at least think about renaming _git_frotz to something less generic. The name tells us that it is a helper shell function about the "git frotz" command, but it does not say what aspect of "git frotz" it is meant to help, i.e. completion. _git_complete_frotz or a variant of such would not have that problem, and will keep the door open for future shell helpers that are about different aspect "xxx" that is unrelated to completion---they can then name theirs _git_xxx_frotz.

> ...  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().

In Hg's context it might make sense to name a function _hg_cmd_foo vs _hg_ext_bar iff the end users need to be very aware of the distinction between commands and extensions, but for us I think "git_cmd_foo" is probably the most meaningless rename, as it doesn't add any extra information (we know 'git foo' is a command already without 'cmd').

Previous: SZEDER GáborNext: Shawn O. Pearce
Message 21 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.