Skip to contentSkip to conversation

bash: Add long option completion for 'git send-email'

PATCH In review Teemu Likonen 3 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bash: Add long option completion for 'git send-email'

Add the following long options to be completed with 'git send-email':

    --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

Short ones like --to and --cc are not usable for actual completion because of the shortness itself and because there are longer ones which start with same letters (--thread, --compose). It's still useful to have these shorter options _listed_ when user presses TAB key after typing two dashes. It gives user an idea what options are available (and --to and --cc are probably the most commonly used).

---
 contrib/completion/git-completion.bash |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +20 -0
index d268e6f..b15f3a9 100755
@@ -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
+}
+
 _git_config ()
 {
 	local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -1376,6 +1394,7 @@ _git ()
 	rebase)      _git_rebase ;;
 	remote)      _git_remote ;;
 	reset)       _git_reset ;;
+	send-email)  _git_send_email ;;
 	shortlog)    _git_shortlog ;;
 	show)        _git_show ;;
 	show-branch) _git_log ;;
@@ -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
Signature · 1 line
1.5.6.3.316.g01fc
#1 lore raw
Quoted 1 line · Teemu Likonen

Add the following long options to be completed with 'git send-email':

...

Quoted 1 line

Short ones like --to and --cc are not usable for actual completion

I agree, these are worth including.

Quoted 14 lines
contrib/completion/git-completion.bash +6 -0
index d268e6f..b15f3a9 100755
@@ -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

contrib/completion/git-completion.bash _git_rebase () · line 923

Quoted 10 lines
contrib/completion/git-completion.bash +10 -0
+			--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.

contrib/completion/git-completion.bash complete -o default -o nospace -F _git_rebase git-rebase · line 1460

Quoted 8 lines
contrib/completion/git-completion.bash +1 -0
@@ -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?

Signature · 1 line
Shawn.
#2 lore raw

PATCH v2 1/1 bash: Teach the bash completion about 'git send-email'

Add the following long options to be completed with 'git send-email':

    --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

Short ones like --to and --cc are not usable for actual completion because of the shortness itself and because there are longer ones which start with same letters (--thread, --compose). It's still useful to have these shorter options _listed_ when user presses TAB key after typing two dashes. It gives user an idea what options are available (and --to and --cc are probably the most commonly used).

---

Shawn O. Pearce wrote (2008-07-15 04:38 +0000):

Quoted 7 lines

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.

Done. And thanks.

Quoted 7 lines
Quoted 1 line

+complete -o default -o nospace -F _git_send_email git-send-email

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?

This is a for-1.6 version so the completion for dashed command (git-send-email) is dropped. I see Shawn already sent a patch which drops all those.

 contrib/completion/git-completion.bash |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +19 -0
index d268e6f..48ebbf7 100755
@@ -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
+	COMPREPLY=()
+}
+
 _git_config ()
 {
 	local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -1376,6 +1394,7 @@ _git ()
 	rebase)      _git_rebase ;;
 	remote)      _git_remote ;;
 	reset)       _git_reset ;;
+	send-email)  _git_send_email ;;
 	shortlog)    _git_shortlog ;;
 	show)        _git_show ;;
 	show-branch) _git_log ;;
Signature · 1 line
1.5.6.3.316.g01fc
Acked-by on v2 1/1
#3 lore raw

Re: [PATCH v2] bash: Teach the bash completion about 'git send-email'

Quoted 9 lines · Teemu Likonen

Add the following long options to be completed with 'git send-email':

    --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
Quoted 8 lines

Short ones like --to and --cc are not usable for actual completion because of the shortness itself and because there are longer ones which start with same letters (--thread, --compose). It's still useful to have these shorter options _listed_ when user presses TAB key after typing two dashes. It gives user an idea what options are available (and --to and --cc are probably the most commonly used).

Thanks for the quick reply cleaning up the minor details. :)

Quoted 69 lines

Shawn O. Pearce wrote (2008-07-15 04:38 +0000):

Quoted 7 lines

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.

Done. And thanks.

Quoted 7 lines
Quoted 1 line

+complete -o default -o nospace -F _git_send_email git-send-email

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?

This is a for-1.6 version so the completion for dashed command (git-send-email) is dropped. I see Shawn already sent a patch which drops all those.

 contrib/completion/git-completion.bash |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)
contrib/completion/git-completion.bash +19 -0
index d268e6f..48ebbf7 100755
@@ -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
+	COMPREPLY=()
+}
+
 _git_config ()
 {
 	local cur="${COMP_WORDS[COMP_CWORD]}"
@@ -1376,6 +1394,7 @@ _git ()
 	rebase)      _git_rebase ;;
 	remote)      _git_remote ;;
 	reset)       _git_reset ;;
+	send-email)  _git_send_email ;;
 	shortlog)    _git_shortlog ;;
 	show)        _git_show ;;
 	show-branch) _git_log ;;
Signature · 1 line
1.5.6.3.316.g01fc
Signature · 1 line
Shawn.
#4 lore raw
In reply to Shawn O. Pearce
Quoted 5 lines · Shawn O. Pearce

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?

Yeah, it is trivial but does it deserve "bugfix -- we need to deliver this change to the end users, otherwise they will suffer" label? Probably not.

#5 lore raw
Quoted 10 lines · Junio C Hamano
Quoted 5 lines · Shawn O. Pearce

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?

Yeah, it is trivial but does it deserve "bugfix -- we need to deliver this change to the end users, otherwise they will suffer" label? Probably not.

Not really, but we have shipped new completion functionality (missing --graph option to git-log) in maint releases in recent history.

If it was me maintaining git.git, I'd probably toss this into maint. But I think I have a more aggressive personality than you, and am more willing to take a risk. Users frequently don't like such risk.

I defer to your wise judgement. Given prior statements about what goes where, you are being consistent to say this should go in 1.6. In which case I suggest Teemu should drop that last hunk as we should really drop that entire block of code from the script.

Signature · 1 line
Shawn.