[PATCH] send-email: add a few config variables.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This adds from, to, suppressfrom and nosignedoffcc configuration
variables to git-send-email, so that these common options do not
have to be given from the command line all the time.

Signed-off-by: Junio C Hamano <junkio@xxxxxxx>
---

 * I do not use send-email myself that often, but it irritated
   me enough that there do not seem to be a way to set these
   common things in the configuration.  Maybe I was missing
   something obvious and this patch is not needed.  I dunno.

 Documentation/git-send-email.txt |   17 +++++++++++++++++
 git-send-email.perl              |   30 +++++++++++++++++++++++++-----
 2 files changed, 42 insertions(+), 5 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 795db87..3435b8c 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -119,6 +119,23 @@ sendemail.chainreplyto::
 	Boolean value specifying the default to the '--chain_reply_to'
 	parameter.
 
+sendemail.fromme::
+	Boolean; when set, use your authorname and authoremail
+	(typically found in `.git/config` as user.name and
+	user.email variables) if `--from` option is not given.
+
+sendemail.to::
+	When `--to` is not specified on the command line, use
+	this address instead.
+
+sendemail.suppressfrom::
+	Boolean; when set, act as if `--suppress-from` is given
+	on the command line.
+
+sendemail.nosignedoffcc::
+	Boolean; when set, act as if `--no-signed-off-cc` is
+	given on the command line.
+
 sendemail.smtpserver::
 	Default smtp server to use.
 
diff --git a/git-send-email.perl b/git-send-email.perl
index a6e3e02..785fb75 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -164,6 +164,18 @@ if (!@bcclist or !$bcclist[0]) {
     @bcclist = ();
 }
 
+my $fromme;
+
+for my $ent (['fromme', \$fromme],
+	     ['suppressfrom', \$suppress_from],
+	     ['nosignedoffcc', \$no_signed_off_cc]) {
+	my $val = $repo->config_boolean('sendemail.' . $ent->[0]);
+	my $var = $ent->[1];
+	${$var} = (! ($val && $val eq 'false'));
+}
+
+my $default_to = $repo->config('sendmail.to');
+
 # Begin by accumulating all the variables (defined above), that we will end up
 # needing, first, from the command line:
 
@@ -187,6 +199,19 @@ unless ($rc) {
     usage();
 }
 
+# Now, let's fill any that aren't set in with defaults:
+
+my ($author) = $repo->ident_person('author');
+my ($committer) = $repo->ident_person('committer');
+
+if ($fromme && !defined $from) {
+	$from = $author;
+}
+
+if (!@to && $default_to ne '') {
+	push @to, $default_to;
+}
+
 # Verify the user input
 
 foreach my $entry (@to) {
@@ -201,11 +226,6 @@ foreach my $entry (@bcclist) {
 	die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/;
 }
 
-# Now, let's fill any that aren't set in with defaults:
-
-my ($author) = $repo->ident_person('author');
-my ($committer) = $repo->ident_person('committer');
-
 my %aliases;
 my @alias_files = $repo->config('sendemail.aliasesfile');
 my $aliasfiletype = $repo->config('sendemail.aliasfiletype');
-- 
1.5.2.rc0.781.g5868


-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]