@matheusbsbs / matheus-bagliano / commits / 6130259c30
Fork 0

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. Signed-off-by: Matthew @ilcox <matthew@wil.cx> Signed-off-by: Junio C Hamano <junkio@cox.net>

Matthew Wilcox committed Oct 10, 2006 at 08:58 UTC 6130259c30695d8a6ceda414a7d0d14183491e82
1 file changed +6 -2
git-send-email.perl
+6 -2
@@ -87,7 +87,8 @@ my (@to,@cc,@initial_cc,@bcclist,
87 $initial_reply_to,$initial_subject,@files,$from,$compose,$time);
88
89 # Behavior modification variables
90 -my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc) = (1, 0, 0, 0);
90 +my ($chain_reply_to, $quiet, $suppress_from, $no_signed_off_cc,
91 + $dry_run) = (1, 0, 0, 0, 0);
92 my $smtp_server;
93
94 # Example reply to:
@@ -116,6 +117,7 @@ my $rc = GetOptions("from=s" => \$from,
117 "quiet" => \$quiet,
118 "suppress-from" => \$suppress_from,
119 "no-signed-off-cc|no-signed-off-by-cc" => \$no_signed_off_cc,
120 + "dry-run" => \$dry_run,
121 );
122
123 # Verify the user input
@@ -423,7 +425,9 @@ X-Mailer: git-send-email $gitversion
425 $header .= "References: $references\n";
426 }
427
426 - if ($smtp_server =~ m#^/#) {
428 + if ($dry_run) {
429 + # We don't want to send the email.
430 + } elsif ($smtp_server =~ m#^/#) {
431 my $pid = open my $sm, '|-';
432 defined $pid or die $!;
433 if (!$pid) {