Re: [PATCH 1/2] send-email: refactor and ensure prompting doesn't loop forever

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jay Soffian <jaysoffian@...>
Cc: <git@...>, Junio C Hamano <gitster@...>
Date: Tuesday, March 31, 2009 - 5:32 am

Jay Soffian <jaysoffian@gmail.com> writes:


Surprising. I did the test with 3 commits to send (titled "hello",
"hello-again" and "hello-oncemore"). the log says this
  
Send this email reply required at /home/moy/local/usr/libexec/git-core//git-send-email line 866.
OK. Log says:
Sendmail: /usr/sbin/sendmail -i Matthieu.Moy@imag.fr
From: Matthieu.Moy@imag.fr
To: Matthieu.Moy@imag.fr
Subject: [PATCH 1/3] hello
Date: Tue, 31 Mar 2009 10:47:59 +0200
Message-Id: <1238489281-5518-1-git-send-email-Matthieu.Moy@imag.fr>
X-Mailer: git-send-email 1.6.2.1.413.gf2ad.dirty

Result: OK
(mbox) Adding cc: moy <moy@973704de-e02c-4a59-87bb-087b52aa604b> from line 'From: moy <moy@973704de-e02c-4a59-87bb-087b52aa604b>'

From: Matthieu.Moy@imag.fr
To: Matthieu.Moy@imag.fr
Subject: [PATCH 2/3] hello-again
Date: Tue, 31 Mar 2009 10:48:00 +0200
Message-Id: <1238489281-5518-2-git-send-email-Matthieu.Moy@imag.fr>
X-Mailer: git-send-email 1.6.2.1.413.gf2ad.dirty
In-Reply-To: <1238489281-5518-1-git-send-email-Matthieu.Moy@imag.fr>
References: <1238489281-5518-1-git-send-email-Matthieu.Moy@imag.fr>

(line 866 is this: die "Send this email reply required" unless defined $_;)

And I received only patch 1/3.

Actually, this seems to be a totally separate issue. What happens is
that for the first email, the script executes :

		if ($needs_confirm eq "inform") {
			$confirm_unconfigured = 0; # squelch this message for the rest of this run
			$ask_default = "y"; # assume yes on EOF since user hasn't explicitly asked for confirmation
			... (show message, ...)
		}
		$_ = ask("Send this email? ([y]es|[n]o|[q]uit|[a]ll): ",
		         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,
		         default => $ask_default);

and the second time, since $confirm_unconfigured = 0 has been set, the
message is not shown again, _and_ $ask_default not set (since
$needs_confirm is set according to $confirm_unconfigured). I think the
solution is to use a variable different from $confirm_unconfigured to
say whether the message has already been displayed, along the lines
of:

diff --git a/git-send-email.perl b/git-send-email.perl
index 5916c86..9e36c35 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -357,6 +357,7 @@ if ($confirm_unconfigured) {
 };
 die "Unknown --confirm setting: '$confirm'\n"
        unless $confirm =~ /^(?:auto|cc|compose|always|never)/;
+my $confirm_msg_shown = undef;
 
 # Debugging, print out the suppressions.
 if (0) {
@@ -844,17 +849,21 @@ X-Mailer: git-send-email $gitversion
                print "\n$header\n";
                my $ask_default;
                if ($needs_confirm eq "inform") {
-                       $confirm_unconfigured = 0; # squelch this message for the rest of this run
                        $ask_default = "y"; # assume yes on EOF since user hasn't explicitly asked for confirmation
-                       print "    The Cc list above has been expanded by additional\n";
-                       print "    addresses found in the patch commit message. By default\n";
-                       print "    send-email prompts before sending whenever this occurs.\n";
-                       print "    This behavior is controlled by the sendemail.confirm\n";
-                       print "    configuration setting.\n";
-                       print "\n";
-                       print "    For additional information, run 'git send-email --help'.\n";
-                       print "    To retain the current behavior, but squelch this message,\n";
-                       print "    run 'git config --global sendemail.confirm auto'.\n\n";
+                       if (!defined $confirm_msg_shown) {
+                               $confirm_msg_shown = 0; # squelch this message for the rest of this run
+                               print "    The Cc list above has been expanded by additional\n";
+                               print "    addresses found in the patch commit message. By default\n";
+                               print "    send-email prompts before sending whenever this occurs.\n";
+                               print "    This behavior is controlled by the sendemail.confirm\n";
+                               print "    configuration setting.\n";
+                               print "\n";
+                               print "    For additional information, run 'git send-email --help'.\n";
+                               print "    To retain the current behavior, but squelch this message,\n";
+                               print "    run 'git config --global sendemail.confirm auto'.\n\n";
+                       }
                }
                $_ = ask("Send this email? ([y]es|[n]o|[q]uit|[a]ll): ",
                         valid_re => qr/^(?:yes|y|no|n|quit|q|all|a)/i,


(worksforme at least)

-- 
Matthieu
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH 1/2] send-email: refactor and ensure prompting do..., Matthieu Moy, (Tue Mar 31, 5:32 am)