Subject: Re: [PATCH] bash completion: Add completion for 'git grep'

From: "Shawn O. Pearce" <[email-masked]>
Date: Sat, 2 Aug 2008 14:05:25 -0700

Lee Marlow <[email-masked]> wrote:
> +_git_grep ()
> +{
> +	__git_has_doubledash && return
> +
> +	local cur="${COMP_WORDS[COMP_CWORD]}"
> +	case "$cur" in
> +	--*)
> +		__gitcomp "
> +			--cached
> +			--text --ignore-case --word-regexp --invert-match
> +			--full-name
> +			--extended-regexp --basic-regexp --fixed-strings
> +			--files-with-matches --name-only
> +			--files-without-match
> +			--count
> +			--and --or --not --all-match
> +			"
> +		return
> +		;;
> +	esac
> +	COMPREPLY=()
> +}

Hmm.  The has_doubledash test seems redundant since we don't do
anything with args that aren't --foo.  Even though git-grep will
accept a tree-ish and thus completion of __git_refs here may
make sense.

I wonder if we shouldn't just add to the end something like:

	__gitcomp "$(__git_refs)"

like the _git_reset function does.  Then we can complete a tree-ish
for searching, as well as honor -- to stop tree-ish completion and
go back to file/directory completion.

But that is very much a user question.  Do users mostly search a
file in the current working directory, or do they mostly search
a tree-ish?

-- 
Shawn.