Subject: Re: [PATCH] git-completion: fix zsh support

From: Jonathan Nieder <[email-masked]>
Date: Tue, 26 Apr 2011 21:21:17 -0500

Felipe Contreras wrote:

> +++ b/contrib/completion/git-completion.bash
[...]
> @@ -739,12 +739,12 @@ __git_complete_revlist ()
>  
>  __git_complete_remote_or_refspec ()
>  {
> -	local cur words cword
> -	_get_comp_words_by_ref -n =: cur words cword
> -	local cmd="${words[1]}"
> +	local cur cwords cword
> +	_get_comp_words_by_ref -n =: cur cwords cword

Hmm, on second thought, this will break the following case, in bash:

	. /etc/bash_completion;	# defines _get_comp_words_by_ref
	. contrib/completion/git-completion.bash

Not sure how to salvage that.  Maybe we need a git-specific API
that wraps _get_comp_words_by_ref when the latter is available.

	if type _get_comp_words_by_ref >/dev/null 2>&1; then
		_git_get_comp_words_by_ref () {
			_get_comp_words_by_ref "$@"
			if test "${words+set}"
			then
				cword="${words[@]}"
			fi
		}
	else
		_git_get_comp_words_by_ref () {
			...
		}
	fi