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

From: "Shawn O. Pearce" <[email-masked]>
Date: Fri, 29 Jan 2010 12:04:31 -0800

SZEDER G?bor <[email-masked]> wrote:
> 
> _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

__git_aliased_command is returning the first word out of the alias.
I think we need to change this block here to:

  case "$expansion" of
  \!*) : leave command as alias ;;
  '')  : leave command alone ;;
  *)   command="$expansion" ;;
  esac

Or something like that.  Because an alias whose value starts with
! is a shell command to be executed, so we want to use _git_$command
for completion, but other aliases are builtin commands and we should
use their first word token (what __git_aliased_command returns)
as the name of the completion function.

I think.  :-)

-- 
Shawn.