Re: [PATCH v2] send-email: add --confirm option
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 3, 2009, 02:47 UTC
- Message-ID
- <7v1vtfjpad.fsf@gitster.siamese.dyndns.org>
- In-Reply-To
- <1235924234-16923-1-git-send-email-jaysoffian@gmail.com>
Jay Soffian <jaysoffian@gmail.com> writes:
> - When the user specifies "all" in response to a confirm prompt, we > hint them about how to use "sendemail.confirm" config setting.
I think the logic is wrong. Even when you have configured to usually ask, you may want to say "I know Cc settings for this particular series is all good, but I still want the safety in my future invocations.".
How about doing it this way instead?
Show 7 quoted lines
> @@ -346,6 +350,13 @@ if ($suppress_cc{'body'}) {
> delete $suppress_cc{'body'};
> }
>
> +# Set confirm
> +if (!defined $confirm) {
> + $confirm = scalar %suppress_cc ? 'compose' : 'auto';This is not "Set confirm" but "set the default value to $confirm". Also set $confirm_unconfigured = "true" here.
> @@ -837,6 +836,27 @@ X-Mailer: git-send-email $gitversion
> unshift (@sendmail_parameters,
> '-f', $raw_from) if(defined $envelope_sender);
> + if ($needs_confirm && !$dry_run) {And use it here; give some help for people who haven't seen this new message and haven't decided:
if (!$confirm_unconfigured) {
print "By default the command asks if you are sure about\n";
print "the CC list computed from various places. If you\n";
print "do not want this confirmation step, you can say\n";
print " $ git config --global sendemail.confirm never\n";
print "to squelch it.\n";
print "A good setting might be:\n";
print " $ git config --global sendemail.confirm auto\n";
print "to squelch this help text that is given until you\n";
print "configure the variable to some value.\n";
}Show 15 quoted lines
> + print "\n$header\n";
> + while (1) {
> + chomp ($_ = $term->readline(
> + "Send this email? ([y]es|[n]o|[q]uit|[a]ll): "
> + ));
> + last if /^(?:yes|y|no|n|quit|q|all|a)/i;
> + print "\n";
> + }
> + if (/^n/i) {
> + return;
> + } elsif (/^q/i) {
> + cleanup_compose_files();
> + exit(0);
> + } elsif (/^a/i) {
> + $confirm = 'never';And drop the following two:
> + print "You may disable all future prompting via sendemail.confirm;\n"; > + print "Run 'git send-email --help' for details.\n"; > + } > + }