git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Remove "uninitialized value" Perl warning
@ 2016-01-12  3:31 Øyvind A. Holm
       [not found] ` <xmqq4meitsce.fsf@gitster.mtv.corp.google.com>
  0 siblings, 1 reply; 2+ messages in thread
From: Øyvind A. Holm @ 2016-01-12  3:31 UTC (permalink / raw)
  To: git; +Cc: jnareb, gitster, Øyvind A. Holm

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2016-01-12 21:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-12  3:31 [PATCH] gitweb: Remove "uninitialized value" Perl warning Øyvind A. Holm
     [not found] ` <xmqq4meitsce.fsf@gitster.mtv.corp.google.com>
2016-01-12 21:20   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).