From: Øyvind A. Holm Date: Tue, 12 Jan 2016 03:31:56 +0000 (+0100) Subject: gitweb: squelch "uninitialized value" warning X-Git-Url: https://git.ladys.computer/Gitweb/commitdiff_plain/82fe7d0b840b89b0ae5c3351e928daef0ec9ef630542cd026040b3333adcf03f gitweb: squelch "uninitialized value" warning git_object() chomps $type that is read from "cat-file -t", but it does so before checking if $type is defined, resulting in 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 Check the value in $type before chomping. This will cause us to call href with its action parameter set to undef when formulating the URL to redirect to, but that is harmless, as the function treats a parameter that set to undef as if it does not exist. Signed-off-by: Øyvind A. Holm Signed-off-by: Junio C Hamano --- diff --git a/gitweb.perl b/gitweb.perl index 9956e59..40730e1 100755 --- a/gitweb.perl +++ b/gitweb.perl @@ -7577,7 +7577,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");