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 4, 2008, 14:53 UTC
Message-ID
<20080804145303.GE27666@spearce.org>
In-Reply-To
<1217638593-57321-1-git-send-email-lee.marlow@gmail.com>
Lee Marlow <lee.marlow@gmail.com> wrote:
Show 11 quoted lines
> Added completions for all long options specified in the docs
> 	--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
> 
> Signed-off-by: Lee Marlow <lee.marlow@gmail.com>
Acked-by: Shawn O. Pearce <spearce@spearce.org>

This is the "first patch" which has the doubledash test. As you pointed out, its better because it stops completion of long options after the --.

Show 43 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index 30d8701..b28ac10 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -796,6 +796,29 @@ _git_gc ()
>  	COMPREPLY=()
>  }
>  
> +_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=()
> +}
> +
>  _git_help ()
>  {
>  	local cur="${COMP_WORDS[COMP_CWORD]}"
> @@ -1486,6 +1509,7 @@ _git ()
>  	fetch)       _git_fetch ;;
>  	format-patch) _git_format_patch ;;
>  	gc)          _git_gc ;;
> +	grep)        _git_grep ;;
>  	help)        _git_help ;;
>  	log)         _git_log ;;
>  	ls-remote)   _git_ls_remote ;;
> -- 
-- 
Shawn.
Previous: Shawn O. Pearce
Message 7 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.