@@ -2359,16 +2359,7 @@ _git_send_email ()
return
;;
--*)
- __gitcomp_builtin send-email "--annotate --bcc --cc --cc-cmd --chain-reply-to
- --compose --confirm= --dry-run --envelope-sender
- --from --identity
- --in-reply-to --no-chain-reply-to --no-signed-off-by-cc
- --no-suppress-from --no-thread --quiet --reply-to
- --signed-off-by-cc --smtp-pass --smtp-server
- --smtp-server-port --smtp-encryption= --smtp-user
- --subject --suppress-cc= --suppress-from --thread --to
- --validate --no-validate
- $__git_format_patch_extra_options"
+ __gitcomp_builtin send-email "$__git_format_patch_extra_options"
return
;;
esac
@@ -38,9 +38,8 @@ sub readline {
package main;
-sub usage {
- print <<EOT;
-git send-email [options] <file | directory | rev-list options >
+my $USAGE = <<EOT
+git send-email [options] <file | directory | rev-list options>
git send-email --dump-aliases
Composing:
@@ -110,11 +109,25 @@ sub usage {
--dump-aliases * Dump configured aliases and exit.
EOT
+;
+
+sub usage {
+ print $USAGE;
exit(1);
}
+sub uniq {
+ my %seen;
+ grep !$seen{$_}++, @_;
+}
+
sub completion_helper {
- print Git::command('format-patch', '--git-completion-helper'), "\n";
+ my @no_only_flags;
+ push @no_only_flags, "--$1", "--no-$1" while ($USAGE =~ /--\[no-](\w+(?:-\w+)*)/g);
+
+ my @all_flags = uniq($USAGE =~ /--\w+(?:-\w+)*/g, @no_only_flags);
+
+ print "@all_flags", Git::command('format-patch', '--git-completion-helper'), "\n";
exit(0);
}
@@ -2139,6 +2139,9 @@ test_expect_success PERL 'send-email' '
--cover-from-description=Z
--cover-letter Z
EOF
+ test_completion "git send-email --val" <<-\EOF &&
+ --validate Z
+ EOF
test_completion "git send-email ma" "main "
'
"git send-email --git-completion-helper" only prints "format-patch" flags. Make it print "send-email" flags as well, generating them programmatically from the usage. Introduce a uniq subroutine, otherwise --dump-aliases would show up twice in the flags. Add a completion test for "send-email --validate", a send-email option. Signed-off-by: Thiago Perrotta <tbperrotta@gmail.com> --- contrib/completion/git-completion.bash | 11 +---------- git-send-email.perl | 21 +++++++++++++++++---- t/t9902-completion.sh | 3 +++ 3 files changed, 21 insertions(+), 14 deletions(-)