threads / discuss / 5679

git send-email woes

Subject: git send-email woes

## tl;dr

6 messages between Sep 24, 2006 and Sep 26, 2006.

replies: 5people: 3as markdown or json

Sam Ravnborg· Sep 24, 2006, 22:43 UTC · lore

I stumbled on two issues with git-send-email today. First of I forgot to tell where to find the patch files to send. But git-send-email only complained _after_ I had given all the information manually. It would have been niver to check that all mandatory arguments was present before being interactive.

The second issue are best explained quoting a mail from Matti Arnio:
Show 10 quoted lines
> > The GIT is at times producing emails that are not
> > utterly strictly speaking kosher RFC-(2)822 format.
> >
> > It might be a surprise to you that unquoted dots in
> > people's names cause syntax scanner indigestion,
> > because said character has very special meaning in
> > RFC-822 syntax.  All would be fine if
> >     Example J.P. Example <example@example.net>
> > had couple quotes:
> >     "Example J.P. Example" <example@example.net>

What I could see was that git-send-email takes mail address verbatim from "Signed-off-by:" lines and use it. Would it be possible to always quote it except when quoted or to do a more intelligent RFC2822 check?

That would keep suprises lower.
I'm not good a perlish so I have not attempted fixing it myself...
	Sam
Sam Ravnborg· Sep 25, 2006, 18:32 UTC · re: Sam Ravnborg · lore

Re: git send-email woes

On Mon, Sep 25, 2006 at 12:43:16AM +0200, Sam Ravnborg wrote:
Show 21 quoted lines
> I stumbled on two issues with git-send-email today.
> First of I forgot to tell where to find the patch files to send.
> But git-send-email only complained _after_ I had given all
> the information manually.
> It would have been niver to check that all mandatory arguments
> was present before being interactive.
> 
> The second issue are best explained quoting a mail from Matti Arnio:
> > > The GIT is at times producing emails that are not
> > > utterly strictly speaking kosher RFC-(2)822 format.
> > >
> > > It might be a surprise to you that unquoted dots in
> > > people's names cause syntax scanner indigestion,
> > > because said character has very special meaning in
> > > RFC-822 syntax.  All would be fine if
> > >     Example J.P. Example <example@example.net>
> > > had couple quotes:
> > >     "Example J.P. Example" <example@example.net>
> 
> What I could see was that git-send-email takes mail address
> verbatim from "Signed-off-by:" lines and use it.

The patches in quistion did not have a "Signed-off-by: tag so that mail address has been from the author instead. And this mail address was still invalid as per RFC2822.

Show 6 quoted lines
> Would it be possible to always quote it except when quoted
> or to do a more intelligent RFC2822 check?
> 
> That would keep suprises lower.
> 
> I'm not good a perlish so I have not attempted fixing it myself...
	Sam
Junio C Hamano· Sep 25, 2006, 19:58 UTC · re: Sam Ravnborg · lore

Re: git send-email woes

Sam Ravnborg <sam@ravnborg.org> writes:
> The patches in quistion did not have a "Signed-off-by: tag so
> that mail address has been from the author instead.
> And this mail address was still invalid as per RFC2822.

I do not think it takes Signed-off-by: as author in any case (and I do not think it should -- if it did so it is a bug).

Maybe something like this?
diff --git a/git-send-email.perl b/git-send-email.perl
index 746c525..b4a34f4 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -431,6 +431,11 @@ sub send_message
 	    $gitversion =~ s/^.* //;
 	}
 
+	my ($author_name) = ($from =~ /^(.*?)\s+</);
+	if ($author_name =~ /\./ && $author_name !~ /^".*"$/) {
+		my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
+		$from = "\"$name\"$addr";
+	}
 	my $header = "From: $from
 To: $to
 Cc: $cc
David Miller· Sep 25, 2006, 21:17 UTC · re: Junio C Hamano · lore

Re: git send-email woes

From: Junio C Hamano <junkio@cox.net>
Date: Mon, 25 Sep 2006 12:58:21 -0700
Show 10 quoted lines
> Sam Ravnborg <sam@ravnborg.org> writes:
> 
> > The patches in quistion did not have a "Signed-off-by: tag so
> > that mail address has been from the author instead.
> > And this mail address was still invalid as per RFC2822.
> 
> I do not think it takes Signed-off-by: as author in any case
> (and I do not think it should -- if it did so it is a bug).
> 
> Maybe something like this?
That looks like it would do the trick.
Sam Ravnborg· Sep 25, 2006, 21:51 UTC · re: Junio C Hamano · lore

Re: git send-email woes

On Mon, Sep 25, 2006 at 12:58:21PM -0700, Junio C Hamano wrote:
Show 28 quoted lines
> Sam Ravnborg <sam@ravnborg.org> writes:
> 
> > The patches in quistion did not have a "Signed-off-by: tag so
> > that mail address has been from the author instead.
> > And this mail address was still invalid as per RFC2822.
> 
> I do not think it takes Signed-off-by: as author in any case
> (and I do not think it should -- if it did so it is a bug).
> 
> Maybe something like this?
> 
> diff --git a/git-send-email.perl b/git-send-email.perl
> index 746c525..b4a34f4 100755
> --- a/git-send-email.perl
> +++ b/git-send-email.perl
> @@ -431,6 +431,11 @@ sub send_message
>  	    $gitversion =~ s/^.* //;
>  	}
>  
> +	my ($author_name) = ($from =~ /^(.*?)\s+</);
> +	if ($author_name =~ /\./ && $author_name !~ /^".*"$/) {
> +		my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
> +		$from = "\"$name\"$addr";
> +	}
>  	my $header = "From: $from
>  To: $to
>  Cc: $cc
> 

I would assume we had to do the same for all mail addresses? In this case also for $to and $cc and $reply_to.

	Sam
Junio C Hamano· Sep 26, 2006, 04:11 UTC · re: Sam Ravnborg · lore

Re: git send-email woes

Sam Ravnborg <sam@ravnborg.org> writes:
Show 15 quoted lines
>> @@ -431,6 +431,11 @@ sub send_message
>>  	    $gitversion =~ s/^.* //;
>>  	}
>>  
>> +	my ($author_name) = ($from =~ /^(.*?)\s+</);
>> +	if ($author_name =~ /\./ && $author_name !~ /^".*"$/) {
>> +		my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
>> +		$from = "\"$name\"$addr";
>> +	}
>>  	my $header = "From: $from
>>  To: $to
>>  Cc: $cc
>> 
> I would assume we had to do the same for all mail addresses?
> In this case also for $to and $cc and $reply_to.

I do not think so, although I admit I only had a cursory look at the code. In this part of the code, $to and $cc are coming from return value of unique_email_list sub, which cleanses each address with extract_valid_address sub. This sub does:

	A U Thor <foo@bar.baz> => foo@bar.baz
In other words, I think it is only "$from" that needs it.

I think $to and $cc should not strip out the human-readable name, but in this case it saved us extra trouble. Sigh...

← back to recent threads