Skip to contentSkip to conversation

Add --dry-run option to git-send-email

PATCH In review Matthew Wilcox 3 participants 3 messages Jun 15, 2016 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Add --dry-run option to git-send-email

Add a --dry-run option to git-send-email due to having made too many mistakes with it in the past week. I like having a safety catch on my machine gun.

git-send-email.perl renamed from usr/bin/git-send-email +6 -2
@@ -40,7 +40,8 @@
 	$initial_reply_to,$initial_subject,@files,$from,$compose,$time);
 
 # Behavior modification variables
-my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc) = (1, 0, 0, 0);
+my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc,
+	$dry_run) = (1, 0, 0, 0, 0);
 my $smtp_server;
 
 # Example reply to:
@@ -63,6 +64,7 @@
 		    "quiet" => \$quiet,
 		    "suppress-from" => \$suppress_from,
 		    "no-signed-off-cc|no-signed-off-by-cc" => \$no_signed_off_cc,
+		    "dry-run" => \$dry_run,
 	 );
 
 # Verify the user input
@@ -395,7 +397,9 @@
 		$header .= "References: $references\n";
 	}
 
-	if ($smtp_server =~ m#^/#) {
+	if ($dry_run) {
+		# We don't want to send the email.
+	} elsif ($smtp_server =~ m#^/#) {
 		my $pid = open my $sm, '|-';
 		defined $pid or die $!;
 		if (!$pid) {
#1 lore raw
Quoted 5 lines · Matthew Wilcox

Add a --dry-run option to git-send-email due to having made too many mistakes with it in the past week. I like having a safety catch on my machine gun.

Good.

When I have to look into other people's issues with send-email, I used to say "--smtp-server=/var/tmp/send" which is this script:

        #!/bin/sh
        for i
        do
                echo "arg $i"
        done
        sed -e 's/^/Msg: /'

I hope your patch makes the above hack unneeded (I want to see what is fed to sendmail, what goes on the header and body).

#2 lore raw
In reply to Matthew Wilcox
Quoted 3 lines · Matthew Wilcox

Add a --dry-run option to git-send-email due to having made too many mistakes with it in the past week.  I like having a safety catch on my machine gun.

+1

I'd like also for git-send-email to check if there are any patches to send, as I oftend did forgot to provide patches.

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git