From: Junio C Hamano Date: Tue, 13 Nov 2018 13:37:28 +0000 (+0900) Subject: Merge branch 'nd/complete-format-patch' X-Git-Tag: v2.20.0-rc0~29 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/95182c65d844e799e80a8f8997e357cdf8a3c7a6?ds=sidebyside;hp=-c Merge branch 'nd/complete-format-patch' The support for format-patch (and send-email) by the command-line completion script (in contrib/) has been simplified a bit. * nd/complete-format-patch: completion: use __gitcomp_builtin for format-patch --- 95182c65d844e799e80a8f8997e357cdf8a3c7a6 diff --combined contrib/completion/git-completion.bash index e9647a103a,8409978793..9e8ec95c3c --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@@ -400,7 -400,7 +400,7 @@@ __gitcomp_builtin ( if [ -z "$options" ]; then # leading and trailing spaces are significant to make # option removal work correctly. - options=" $(__git ${cmd/_/ } --git-completion-helper) $incl " + options=" $incl $(__git ${cmd/_/ } --git-completion-helper) " for i in $excl; do options="${options/ $i / }" done @@@ -1341,6 -1341,17 +1341,6 @@@ _git_checkout ( esac } -_git_cherry () -{ - case "$cur" in - --*) - __gitcomp_builtin cherry - return - esac - - __git_complete_refs -} - __git_cherry_pick_inprogress_options="--continue --quit --abort" _git_cherry_pick () @@@ -1521,13 -1532,9 +1521,9 @@@ _git_fetch ( __git_complete_remote_or_refspec } - __git_format_patch_options=" - --stdout --attach --no-attach --thread --thread= --no-thread - --numbered --start-number --numbered-files --keep-subject --signoff - --signature --no-signature --in-reply-to= --cc= --full-index --binary - --not --all --cover-letter --no-prefix --src-prefix= --dst-prefix= - --inline --suffix= --ignore-if-in-upstream --subject-prefix= - --output-directory --reroll-count --to= --quiet --notes + __git_format_patch_extra_options=" + --full-index --not --all --no-prefix --src-prefix= + --dst-prefix= --notes " _git_format_patch () @@@ -1540,7 -1547,7 +1536,7 @@@ return ;; --*) - __gitcomp "$__git_format_patch_options" + __gitcomp_builtin format-patch "$__git_format_patch_extra_options" return ;; esac @@@ -1822,7 -1829,7 +1818,7 @@@ _git_mergetool ( return ;; --*) - __gitcomp "--tool= --prompt --no-prompt" + __gitcomp "--tool= --prompt --no-prompt --gui --no-gui" return ;; esac @@@ -2070,7 -2077,7 +2066,7 @@@ _git_send_email ( return ;; --*) - __gitcomp "--annotate --bcc --cc --cc-cmd --chain-reply-to + __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 @@@ -2079,7 -2086,7 +2075,7 @@@ --smtp-server-port --smtp-encryption= --smtp-user --subject --suppress-cc= --suppress-from --thread --to --validate --no-validate - $__git_format_patch_options" + $__git_format_patch_extra_options" return ;; esac diff --combined git-send-email.perl index 4b9d3ad1bd,ed0714eaaa..8eb63b5a2f --- a/git-send-email.perl +++ b/git-send-email.perl @@@ -82,11 -82,8 +82,11 @@@ git send-email --dump-aliase Pass an empty string to disable certificate verification. --smtp-domain * The domain name sent to HELO/EHLO handshake - --smtp-auth * Space-separated list of allowed AUTH mechanisms. + --smtp-auth * Space-separated list of allowed AUTH mechanisms, or + "none" to disable authentication. This setting forces to use one of the listed mechanisms. + --no-smtp-auth Disable SMTP authentication. Shorthand for + `--smtp-auth=none` --smtp-debug <0|1> * Disable, enable Net::SMTP debug. --batch-size * send max message per connection. @@@ -97,7 -94,7 +97,7 @@@ --identity * Use the sendemail. options. --to-cmd * Email To: via ` \$patch_path` --cc-cmd * Email Cc: via ` \$patch_path` - --suppress-cc * author, self, sob, cc, cccmd, body, bodycc, all. + --suppress-cc * author, self, sob, cc, cccmd, body, bodycc, misc-by, all. --[no-]cc-cover * Email Cc: addresses in the cover letter. --[no-]to-cover * Email To: addresses in the cover letter. --[no-]signed-off-by-cc * Send to Signed-off-by: addresses. Default on. @@@ -122,6 -119,11 +122,11 @@@ EO exit(1); } + sub completion_helper { + print Git::command('format-patch', '--git-completion-helper'); + exit(0); + } + # most mail servers generate the Date: header, but not all... sub format_2822_time { my ($time) = @_; @@@ -314,6 -316,7 +319,7 @@@ $SIG{INT} = \&signal_handler # needing, first, from the command line: my $help; + my $git_completion_helper; my $rc = GetOptions("h" => \$help, "dump-aliases" => \$dump_aliases); usage() unless $rc; @@@ -344,7 -347,6 +350,7 @@@ $rc = GetOptions "smtp-debug:i" => \$debug_net_smtp, "smtp-domain:s" => \$smtp_domain, "smtp-auth=s" => \$smtp_auth, + "no-smtp-auth" => sub {$smtp_auth = 'none'}, "identity=s" => \$identity, "annotate!" => \$annotate, "no-annotate" => sub {$annotate = 0}, @@@ -377,9 -379,11 +383,11 @@@ "no-xmailer" => sub {$use_xmailer = 0}, "batch-size=i" => \$batch_size, "relogin-delay=i" => \$relogin_delay, + "git-completion-helper" => \$git_completion_helper, ); usage() if $help; + completion_helper() if $git_completion_helper; unless ($rc) { usage(); } @@@ -458,13 -462,13 +466,13 @@@ my(%suppress_cc) if (@suppress_cc) { foreach my $entry (@suppress_cc) { die sprintf(__("Unknown --suppress-cc field: '%s'\n"), $entry) - unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc)$/; + unless $entry =~ /^(?:all|cccmd|cc|author|self|sob|body|bodycc|misc-by)$/; $suppress_cc{$entry} = 1; } } if ($suppress_cc{'all'}) { - foreach my $entry (qw (cccmd cc author self sob body bodycc)) { + foreach my $entry (qw (cccmd cc author self sob body bodycc misc-by)) { $suppress_cc{$entry} = 1; } delete $suppress_cc{'all'}; @@@ -475,7 -479,7 +483,7 @@@ $suppress_cc{'self'} = $suppress_from i $suppress_cc{'sob'} = !$signed_off_by_cc if defined $signed_off_by_cc; if ($suppress_cc{'body'}) { - foreach my $entry (qw (sob bodycc)) { + foreach my $entry (qw (sob bodycc misc-by)) { $suppress_cc{$entry} = 1; } delete $suppress_cc{'body'}; @@@ -1245,7 -1249,7 +1253,7 @@@ sub smtp_host_string # (smtp_user was not specified), and 0 otherwise. sub smtp_auth_maybe { - if (!defined $smtp_authuser || $auth) { + if (!defined $smtp_authuser || $auth || (defined $smtp_auth && $smtp_auth eq "none")) { return 1; } @@@ -1685,7 -1689,7 +1693,7 @@@ sub process_file # Now parse the message body while(<$fh>) { $message .= $_; - if (/^(Signed-off-by|Cc): (.*)/i) { + if (/^([a-z-]*-by|Cc): (.*)/i) { chomp; my ($what, $c) = ($1, $2); # strip garbage for the address we'll use: @@@ -1695,18 -1699,8 +1703,18 @@@ if ($sc eq $sender) { next if ($suppress_cc{'self'}); } else { - next if $suppress_cc{'sob'} and $what =~ /Signed-off-by/i; - next if $suppress_cc{'bodycc'} and $what =~ /Cc/i; + if ($what =~ /^Signed-off-by$/i) { + next if $suppress_cc{'sob'}; + } elsif ($what =~ /-by$/i) { + next if $suppress_cc{'misc-by'}; + } elsif ($what =~ /Cc/i) { + next if $suppress_cc{'bodycc'}; + } + } + if ($c !~ /.+@.+|<.+>/) { + printf("(body) Ignoring %s from line '%s'\n", + $what, $_) unless $quiet; + next; } push @cc, $c; printf(__("(body) Adding cc: %s from line '%s'\n"), @@@ -1848,7 -1842,7 +1856,7 @@@ sub apply_transfer_encoding my $from = shift; my $to = shift; - return $message if ($from eq $to and $from ne '7bit'); + return ($message, $to) if ($from eq $to and $from ne '7bit'); require MIME::QuotedPrint; require MIME::Base64;