threads / discuss / 6126

git-1.4.4.3, also 1.5.0rc0: send-email gets empty From:

Subject: git-1.4.4.3, also 1.5.0rc0: send-email gets empty From:

## tl;dr

4 messages between Dec 27, 2006 and Jan 19, 2007.

replies: 3people: 3as markdown or json

Horst H. von Brand· Dec 27, 2006, 13:43 UTC · lore
I updated a local project, git-format-patch:ed, and then:
  $ git send-email --to=olpc@listas.inf.utfsm.cl --no-signed-off-by-cc /tmp/0001-Add-myself-to-AUTHORS.txt
  Who should the emails appear to be from? 
  Emails will be sent from: 
  Message-ID to be used as In-Reply-To for the first email? 
  /tmp/0001-Add-myself-to-AUTHORS.txt
  Use of uninitialized value in concatenation (.) or string at /usr/bin/git-send-email line 392.
  (mbox) Adding cc: Horst H. von Brand <vonbrand@inf.utfsm.cl> from line 'From: Horst H. von Brand <vonbrand@inf.utfsm.cl>'
  OK. Log says:
  Date: Wed, 27 Dec 2006 10:27:39 -0300
  Sendmail: /usr/sbin/sendmail
  From: 
  Subject: [PATCH] Add myself to AUTHORS
  Cc: Horst H. von Brand <vonbrand@inf.utfsm.cl>
  To: olpc@listas.inf.utfsm.cl
  Result: OK

I didn't add a From:, per manpage it is assumed to be GIT_COMMITER_IDENT (from 'git-var -l' this is 'Horst H. von Brand <vonbrand@inf.utfsm.cl> 1167226309 -0300'). Note particularly the "Emails will be sent from:" line!

The resulting message is formed right (it has a From: header), so this is just a UI glitch.

The same output from 1.5.0rc0 here.
-- 
Dr. Horst H. von Brand                   User #22616 counter.li.org
Departamento de Informatica                    Fono: +56 32 2654431
Universidad Tecnica Federico Santa Maria             +56 32 2654239
Casilla 110-V, Valparaiso, Chile               Fax:  +56 32 2797513
Quy Tonthat· Dec 27, 2006, 14:16 UTC · re: Horst H. von Brand · lore

[PATCH] git-send-email: default value for "From:" field.

If user hits enter at the prompt for "Who should the emails appear to be from?", the value for "From:" field was emptied instead of GIT_COMMITER_IDENT.

Signed-off-by: Quy Tonthat <qtonthat@gmail.com>
---
It seems the original code assumes readline to accept
an extra argument for default value. I don't remember I ever encountered
that feature from readline. Is there anything like that out there ?
 git-send-email.perl |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index 4c87c20..ba39d39 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -178,11 +178,10 @@ my $prompting = 0;
 if (!defined $from) {
 	$from = $author || $committer;
 	do {
-		$_ = $term->readline("Who should the emails appear to be from? ",
-			$from);
+		$_ = $term->readline("Who should the emails appear to be from? [$from] ");
 	} while (!defined $_);
 
-	$from = $_;
+	$from = $_ if ($_);
 	print "Emails will be sent from: ", $from, "\n";
 	$prompting++;
 }
-- 
1.4.4.3.q5
Timur Tabi· Jan 18, 2007, 20:39 UTC · re: Quy Tonthat · lore

Re: [PATCH] git-send-email: default value for "From:" field.

Quy Tonthat wrote:
Show 9 quoted lines
> If user hits enter at the prompt for
> "Who should the emails appear to be from?",
> the value for "From:" field was emptied instead of GIT_COMMITER_IDENT.
> 
> Signed-off-by: Quy Tonthat <qtonthat@gmail.com>
> ---
> It seems the original code assumes readline to accept
> an extra argument for default value. I don't remember I ever encountered
> that feature from readline. Is there anything like that out there ?

I was thinking the same thing. Almost every call to readline() in git-send-email is like that, so could your patch below could be expanded to include the other instances?

         $_ = $term->readline("Who should the emails be sent to? ",
                         "");
         $_ = $term->readline("What subject should the emails start with? ",
                 $initial_subject);
         $_= $term->readline("Message-ID to be used as In-Reply-To for the first 
email? ",
                 $initial_reply_to);
-- 
Timur Tabi
Linux Kernel Developer @ Freescale
Quy Tonthat· Jan 19, 2007, 01:14 UTC · re: Timur Tabi · lore

Re: [PATCH] git-send-email: default value for "From:" field.

Timur Tabi wrote:
Show 25 quoted lines
> Quy Tonthat wrote:
>> If user hits enter at the prompt for
>> "Who should the emails appear to be from?",
>> the value for "From:" field was emptied instead of GIT_COMMITER_IDENT.
>>
>> Signed-off-by: Quy Tonthat <qtonthat@gmail.com>
>> ---
>> It seems the original code assumes readline to accept
>> an extra argument for default value. I don't remember I ever encountered
>> that feature from readline. Is there anything like that out there ?
> 
> I was thinking the same thing.  Almost every call to readline() in
> git-send-email is like that, so could your patch below could be expanded
> to include the other instances?
> 
>         $_ = $term->readline("Who should the emails be sent to? ",
>                         "");
> 
>         $_ = $term->readline("What subject should the emails start with? ",
>                 $initial_subject);
> 
>         $_= $term->readline("Message-ID to be used as In-Reply-To for
> the first email? ",
>                 $initial_reply_to);
> 

It is correct to expand the fix to other instances, but that won't practically change anything at run time (All those "defaults" are empty when passed to readline). I don't normally change somebody else's codes just for the sake of correctness or styles. Quy

← back to recent threads