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

[PATCH] gitweb: Remove "uninitialized value" Perl warning

From
Øyvind A. Holm <sunny@sunbase.org>
Date
Jan 12, 2016, 03:31 UTC
Message-ID
<1452569516-25657-1-git-send-email-sunny@sunbase.org>

git_object(): Check if $type is defined before chomping it. This removes a Perl warning in the server error log:

  gitweb.cgi: Use of uninitialized value $type in scalar chomp at
  [...]/gitweb.cgi line 7579., referer: [...]
when trying to access a non-existing commit, for example:
  http://HOST/?p=PROJECT.git;a=commit;h=NON_EXISTING_COMMIT
Signed-off-by: Øyvind A. Holm <sunny@sunbase.org>
---
 gitweb/gitweb.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 7a5b23a..05d7910 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -7576,7 +7576,7 @@ sub git_object {
 			git_cmd(), 'cat-file', '-t', $object_id) . ' 2> /dev/null'
 			or die_error(404, "Object does not exist");
 		$type = <$fd>;
-		chomp $type;
+		defined $type && chomp $type;
 		close $fd
 			or die_error(404, "Object does not exist");
 
-- 
2.7.0
Next: Junio C Hamano
Message 1 of 2 in “gitweb: Remove "uninitialized value" Perl warning”
  1. gitweb: Remove "uninitialized value" Perl warningØyvind A. Holm, Jan 12, 2016
  2. Junio C HamanoJan 12, 2016

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.