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

From: SZEDER Gábor <[email-masked]>
Date: Fri, 29 Jan 2010 21:00:33 +0100

Hi Shawn,

On Fri, Jan 29, 2010 at 11:13:26AM -0800, Shawn O. Pearce wrote:
> SZEDER G?bor <[email-masked]> wrote:
> > How about something like this for subcommands (not aliases)?  It's a
> > good code size reduction anyway.
> 
> Hmm, I like this.  I just didn't know how to implement it...  :-)
> 
> Acked-by: Shawn O. Pearce <[email-masked]>
> 
> > +	local completion_func="_git_${command//-/_}"
> > +	declare -F $completion_func >/dev/null && $completion_func
> 
> Yay for knowing bash.  :-)

Heh.  I've found out about this 'declare -F' thing about two hours ago
(;

However.

I thought this should actually "Just Work" for aliases, too.  e.g.
Junio could use the following completion function to get 'git log's
options for his lgm alias:

_git_lgm () {
        _git_log
}

Unfortunately, it doesn't work at all.

In _git() first we have 'lgm' in $command, which is ok, but then comes
this alias handling thing

        local expansion=$(__git_aliased_command "$command")
        [ "$expansion" ] && command="$expansion"

which writes '!sh' into $command, and that doesn't look quite right
for me, although I admit that I can't seem to figure out how this
__git_aliased_command() is supposed to work (so much about knowing
bash ;).  Any insight?

Best,
Gábor