git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Shawn O. Pearce <spearce@spearce.org>
Date
Aug 2, 2008, 21:05 UTC
Message-ID
<20080802210525.GD24723@spearce.org>
In-Reply-To
<1217638593-57321-1-git-send-email-lee.marlow@gmail.com>
Lee Marlow <lee.marlow@gmail.com> wrote:
Show 22 quoted lines
> +_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.
Previous: Lee MarlowNext: Lee Marlow
Message 2 of 7 in “bash completion: Add completion for 'git grep'”
  1. bash completion: Add completion for 'git grep'Lee Marlow, Aug 2, 2008
  2. Shawn O. PearceAug 2, 2008
  3. Lee MarlowAug 3, 2008
  4. Shawn O. PearceAug 4, 2008
  5. bash completion: Add completion for 'git grep'Lee Marlow, Aug 4, 2008
  6. Shawn O. PearceAug 4, 2008
  7. Shawn O. PearceAug 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.