Subject: Re: [PATCH] bash: __git_find_subcommand function

From: "Shawn O. Pearce" <[email-masked]>
Date: Fri, 7 Mar 2008 21:23:42 -0500

SZEDER Gbor <[email-masked]> wrote:
> This enables us to remove code duplications from completion
> functions for commands having subcommands.
> 
> Signed-off-by: SZEDER Gábor <[email-masked]>
> ---
> This function does not return the index of the subcommand found on the
> command line, which was in the $c variable previously.  However, $c was
> only used in if statements, like:
> 	if [ $c -eq $COMP_CWORD -a -z "$command" ]; then
> 		__gitcomp "cmd1 cmd2 cmd3"
> 	fi
> To my understanding the only(?) purpose of those if statements was to
> prevent subcommands appearing again on the list of possible completions,
> when there was one already on the command line.  But [ -z $command ] is
> sufficient to detect those cases, so we can actually omit
> [ $c -eq $COMP_CWORD ].  Is it right, or am I missing something?

Yup, you understood it correctly.  You found a cluster of "copy and
paste programming" and I am happy to see it cleaned up.  Thanks.

-- 
Shawn.