git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Apology/Bug report: git-send-email sends everything on Ctrl+C

From
Sam Vilain <sam@vilain.net>
Date
May 26, 2010, 09:27 UTC
Message-ID
<4BFCE973.3000304@vilain.net>
In-Reply-To
<4BFCE6DD.4030403@drmicha.warpmail.net>
Michael J Gruber wrote:
Show 7 quoted lines
> > > Hard to know what could have possibly stopped this from happening.
> > > PEBKAC.
> > Perhaps git can be smart and ask for confirmation for huge (>20 ?)
> > patchsets.
> to be overriden by an option "--no-villain"...
> 
> Sorry, bad joke, but couldn't resist. Feel free to pick on my name ;)
I went with the simpler and pre-existing --confirm=never :-)
Subject: [PATCH] send-email: confirm for really large patch sets

It is possible to send a lot of e-mails using quite simple user errors with git send-email; if they were not intended this could be quite a lot of spam. Ask a final question if there are a lot of messages before sending.

Signed-off-by: Sam Vilain <sam@vilain.net>
---
 untested: after what just happens there is no way I'm testing this :-)
 git-send-email.perl |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 12622fc..093b7f2 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -257,6 +257,11 @@ Administering
 Default is the value of 'sendemail.confirm' configuration value; if that
 is unspecified, default to 'auto' unless any of the suppress options
 have been specified, in which case default to 'compose'.
++
+If you are sending a very large patch sequence (more than 20 parts),
+you will be asked for a second final confirmation before anything is
+sent.  This can be suppressed by setting this configuration value to
+'never'.
 
 --dry-run::
        Do everything except actually send the emails.
diff --git a/git-send-email.perl b/git-send-email.perl
index 111c981..2775506 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -1096,6 +1096,19 @@ $references = $initial_reply_to || '';
 $subject = $initial_subject;
 $message_num = 0;
 
+if ($needs_confirm ne "never" and @files > 20) {
+	$_ = ask(
+		"That's a big patch set - ".@files." parts.  "
+		."Are you sure you want to do this? ([y]es|[n]o): ",
+		valid_re => qr/^(?:yes|y|no|n)/i,
+		default => "n",
+	       );
+	if (/^n/i) {
+		cleanup_compose_files();
+		exit(0);
+	}
+}
+
 foreach my $t (@files) {
 	open(F,"<",$t) or die "can't open file $t";
 
-- 
1.7.1.rc2.333.gb2668
Previous: Michael J GruberNext: Michael J Gruber
Message 7 of 8 in “Apology/Bug report: git-send-email sends everything on Ctrl+C”
  1. Sam VilainMay 26, 2010
  2. Sam VilainMay 26, 2010
  3. Will PalmerMay 26, 2010
  4. Sam VilainMay 26, 2010
  5. Sverre RabbelierMay 26, 2010
  6. Michael J GruberMay 26, 2010
  7. Sam VilainMay 26, 2010
  8. Michael J GruberMay 26, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.