[PATCH] git-send-email: add option to force a From: line within the message body

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

 



From: Brandon Casey <drafnel@xxxxxxxxx>

Add a new command line option --add-author-from and a config option
sendemail.addauthorfrom which will ensure that a From: line is added
to the message body regardless of whether the sender email matches the
From: line parsed from the supplied patch (i.e. the patch author).

This provides a work-around for mail gateways which override the From:
line of submitted messages.

Signed-off-by: Brandon Casey <drafnel@xxxxxxxxx>
---

I don't know if anyone else has the same problem, but I sometimes use a
mail gateway which forces a certain From: line overriding what is
supplied in the email. So, for me, the solution this patch provides could
be achieved by just typing in some bogus string when git-send-email prompts
for the From address, but this patch is more convenient and more general.

-brandon


 Documentation/git-send-email.txt |    9 +++++++++
 git-send-email.perl              |   12 ++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index 336d797..e3267de 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -157,6 +157,11 @@ user is prompted for a password while the input is masked for privacy.
 	if that is unspecified, default to 'self' if --suppress-from is
 	specified, as well as 'sob' if --no-signed-off-cc is specified.
 
+--add-author-from::
+	Add a "From:" line within the message body describing the patch
+	author even if the author is equal to the sender. Usually, a "From:"
+	line is added only when the author differs from the sender.
+
 --thread, --no-thread::
 	If this is set, the In-Reply-To header will be set on each email sent.
 	If disabled with "--no-thread", no emails will have the In-Reply-To
@@ -225,6 +230,10 @@ sendemail.smtppass::
 sendemail.smtpssl::
 	Boolean value specifying the default to the '--smtp-ssl' parameter.
 
+sendemail.addauthorfrom::
+	Boolean value specifying the default to the '--add-author-from'
+	parameter.
+
 Author
 ------
 Written by Ryan Anderson <ryan@xxxxxxxxxxxxxx>
diff --git a/git-send-email.perl b/git-send-email.perl
index 29b1105..4d0aaac 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -94,6 +94,9 @@ Options:
 
    --suppress-from Suppress sending emails to yourself. Defaults to off.
 
+   --add-author-from Add "From:" line within message body for patch author
+                  even when author is equal to sender.
+
    --thread       Specify that the "In-Reply-To:" header should be set on all
                   emails. Defaults to on.
 
@@ -187,6 +190,7 @@ my ($smtp_server, $smtp_server_port, $smtp_authuser, $smtp_ssl);
 my ($identity, $aliasfiletype, @alias_files, @smtp_host_parts);
 my ($no_validate);
 my (@suppress_cc);
+my ($force_author_from);
 
 my %config_bool_settings = (
     "thread" => [\$thread, 1],
@@ -194,6 +198,7 @@ my %config_bool_settings = (
     "suppressfrom" => [\$suppress_from, undef],
     "signedoffcc" => [\$signed_off_cc, undef],
     "smtpssl" => [\$smtp_ssl, 0],
+    "addauthorfrom" => [\$force_author_from, 0],
 );
 
 my %config_settings = (
@@ -252,6 +257,7 @@ my $rc = GetOptions("sender|from=s" => \$sender,
 		    "quiet" => \$quiet,
 		    "cc-cmd=s" => \$cc_cmd,
 		    "suppress-from!" => \$suppress_from,
+		    "add-author-from!" => \$force_author_from,
 		    "suppress-cc=s" => \@suppress_cc,
 		    "signed-off-cc|signed-off-by-cc!" => \$signed_off_cc,
 		    "dry-run" => \$dry_run,
@@ -802,6 +808,12 @@ foreach my $t (@files) {
 
 				} elsif (/^(Cc|From):\s+(.*)$/) {
 					if (unquote_rfc2047($2) eq $sender) {
+						if ($force_author_from &&
+						    $1 eq 'From') {
+							($author,
+							 $author_encoding) =
+							unquote_rfc2047($2)
+						}
 						next if ($suppress_cc{'self'});
 					}
 					elsif ($1 eq 'From') {
-- 
1.5.4.3.472.gdf7d.dirty

--
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]

  Powered by Linux