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

Re: [PATCH] bash: Add long option completion for 'git send-email'

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jul 15, 2008, 04:38 UTC
Message-ID
<20080715043839.GE2432@spearce.org>
In-Reply-To
<1216023662-9109-1-git-send-email-tlikonen@iki.fi>
Teemu Likonen <tlikonen@iki.fi> wrote:
> Add the following long options to be completed with 'git send-email':
...
> Short ones like --to and --cc are not usable for actual completion
I agree, these are worth including.
Show 24 quoted lines
> diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
> index d268e6f..b15f3a9 100755
> --- a/contrib/completion/git-completion.bash
> +++ b/contrib/completion/git-completion.bash
> @@ -905,6 +905,24 @@ _git_rebase ()
>  	__gitcomp "$(__git_refs)"
>  }
>  
> +_git_send_email ()
> +{
> +	local cur="${COMP_WORDS[COMP_CWORD]}"
> +	case "$cur" in
> +	--*)
> +		__gitcomp "--bcc --cc --cc-cmd --chain-reply-to --compose
> +			--dry-run --envelope-sender --from --identity
> +			--in-reply-to --no-chain-reply-to --no-signed-off-by-cc
> +			--no-suppress-from --no-thread --quiet
> +			--signed-off-by-cc --smtp-pass --smtp-server
> +			--smtp-server-port --smtp-ssl --smtp-user --subject
> +			--suppress-cc --suppress-from --thread --to"
> +		return
> +		;;
> +	esac
> +	__git_complete_file

Don't use __git_complete_file here. As far as I remember, git-send-email does not accept "origin/maint:some.patch" as an email to extract from Git prior to sending. It looks for files in the local filesystem. So you want standard bash completion for anything not starting with --.

Just use COMPREPLY=() at the end.  See _git_am for an example.
Show 8 quoted lines
> @@ -1435,6 +1454,7 @@ complete -o default -o nospace -F _git_rebase git-rebase
>  complete -o default -o nospace -F _git_config git-config
>  complete -o default -o nospace -F _git_remote git-remote
>  complete -o default -o nospace -F _git_reset git-reset
> +complete -o default -o nospace -F _git_send_email git-send-email
>  complete -o default -o nospace -F _git_shortlog git-shortlog
>  complete -o default -o nospace -F _git_show git-show
>  complete -o default -o nospace -F _git_stash git-stash
Hmm.  With dash form commands gone in 1.6 we should remove these.

But I suspect this completion patch could be shipped in the next 1.5.6 maint release as its really quite trivial. Junio, any comment on that?

-- 
Shawn.
Previous: Teemu LikonenNext: Junio C Hamano
Message 2 of 6 in “bash: Add long option completion for 'git send-email'”
  1. bash: Add long option completion for 'git send-email'Teemu Likonen, Jul 14, 2008
  2. Shawn O. PearceJul 15, 2008
  3. Junio C HamanoJul 15, 2008
  4. Shawn O. PearceJul 15, 2008
  5. bash: Teach the bash completion about 'git send-email'Teemu Likonen, Jul 15, 2008
  6. Shawn O. PearceJul 15, 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.