git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] Don't use $author_name undefined when $from contains no /\s</.

From
Jim Meyering <jim@meyering.net>
Date
Oct 19, 2006, 08:33 UTC
Message-ID
<87vemgn1s2.fsf@rho.meyering.net>

I noticed a case not handled in a recent patch. Demonstrate it like this:

  $ touch new-file
  $ git-send-email --dry-run --from j --to k new-file 2>err
  new-file
  OK. Log says:
  Date: Thu, 19 Oct 2006 10:26:24 +0200
  Sendmail: /usr/sbin/sendmail
  From: j
  Subject:
  Cc:
  To: k
  Result: OK
  $ cat err
  Use of uninitialized value in pattern match (m//) at /p/bin/git-send-email line 416.
  Use of uninitialized value in concatenation (.) or string at /p/bin/git-send-email line 420.
  Use of uninitialized value in concatenation (.) or string at /p/bin/git-send-email line 468.
There's a patch for the $author_name part below.

The example above shows that $subject may also be used uninitialized. That should be easy to fix, too.

Signed-off-by: Jim Meyering <jim@meyering.net>
---
 git-send-email.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index b17d261..1c6d2cc 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -412,7 +412,7 @@ sub send_message
 	}

 	my ($author_name) = ($from =~ /^(.*?)\s+</);
-	if ($author_name =~ /\./ && $author_name !~ /^".*"$/) {
+	if ($author_name && $author_name =~ /\./ && $author_name !~ /^".*"$/) {
 		my ($name, $addr) = ($from =~ /^(.*?)(\s+<.*)/);
 		$from = "\"$name\"$addr";
 	}
--
1.4.3.g72bb
Next: Junio C Hamano
Message 1 of 10 in “Don't use $author_name undefined when $from contains no /\s</.”
  1. Don't use $author_name undefined when $from contains no /\s</.Jim Meyering, Oct 19, 2006
  2. Junio C HamanoOct 19, 2006
  3. Jim MeyeringOct 19, 2006
  4. Junio C HamanoOct 19, 2006
  5. Paul EggertOct 19, 2006
  6. Junio C HamanoOct 19, 2006
  7. Paul EggertOct 19, 2006
  8. Junio C HamanoOct 20, 2006
  9. Linus TorvaldsOct 20, 2006
  10. Jakub NarebskiOct 20, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.