Merge git://git.kernel.org/pub/scm/gitk/gitk
[gitweb.git] / git-send-email.perl
index ec1428d961206f12e195274aea6ea3ae52374898..3f1b3ca78897ef1eb85dea266eea6afcc404a1db 100755 (executable)
@@ -34,7 +34,7 @@
 my (@to,@cc,$initial_reply_to,$initial_subject,@files,$from,$compose);
 
 # Behavior modification variables
-my ($chain_reply_to, $smtp_server) = (1, "localhost");
+my ($chain_reply_to, $smtp_server, $quiet) = (1, "localhost", 0);
 
 # Example reply to:
 #$initial_reply_to = ''; #<20050203173208.GA23964@foobar.com>';
@@ -51,6 +51,7 @@
                    "chain-reply-to!" => \$chain_reply_to,
                    "smtp-server=s" => \$smtp_server,
                    "compose" => \$compose,
+                   "quiet" => \$quiet,
         );
 
 # Now, let's fill any that aren't set in with defaults:
        # effort to have it be unique
        open(C,">",$compose_filename)
                or die "Failed to open for writing $compose_filename: $!";
-       print C "From \n";
+       print C "From $from # This line is ignored.\n";
        printf C "Subject: %s\n\n", $initial_subject;
        printf C <<EOT;
 GIT: Please enter your email below.
 }
 
 if (@files) {
-       print $_,"\n" for @files;
+       unless ($quiet) {
+               print $_,"\n" for (@files);
+       }
 } else {
        print <<EOT;
 git-send-email [options] <file | directory> [... file | directory ]
    --smtp-server  If set, specifies the outgoing SMTP server to use.
                   Defaults to localhost.
 
+   --quiet     Make git-send-email less verbose.  One line per email should be
+               all that is output.
+
+
 Error: Please specify a file or a directory on the command line.
 EOT
        exit(1);
@@ -267,8 +274,12 @@ sub send_message
 
        sendmail(%mail) or die $Mail::Sendmail::error;
 
-       print "OK. Log says:\n", $Mail::Sendmail::log;
-       print "\n\n"
+       if ($quiet) {
+               printf "Sent %s\n", $subject;
+       } else {
+               print "OK. Log says:\n", $Mail::Sendmail::log;
+               print "\n\n"
+       }
 }
 
 
@@ -277,7 +288,6 @@ sub send_message
 $subject = $initial_subject;
 
 foreach my $t (@files) {
-       my $F = $t;
        open(F,"<",$t) or die "can't open file $t";
 
        @cc = ();
@@ -295,7 +305,7 @@ sub send_message
 
                                } elsif (/^(Cc|From):\s+(.*)$/) {
                                        printf("(mbox) Adding cc: %s from line '%s'\n",
-                                               $2, $_);
+                                               $2, $_) unless $quiet;
                                        push @cc, $2;
                                }
 
@@ -307,7 +317,7 @@ sub send_message
                                # So let's support that, too.
                                if (@cc == 0) {
                                        printf("(non-mbox) Adding cc: %s from line '%s'\n",
-                                               $_, $_);
+                                               $_, $_) unless $quiet;
 
                                        push @cc, $_;
 
@@ -327,7 +337,7 @@ sub send_message
                                chomp $c;
                                push @cc, $c;
                                printf("(sob) Adding cc: %s from line '%s'\n",
-                                       $c, $_);
+                                       $c, $_) unless $quiet;
                        }
                }
        }