Thread (4 messages) flat view 4 messages, 3 authors, 2016-06-15

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

From: SZEDER Gábor <hidden>
Date: 2016-06-15 22:48:21

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.
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help