git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Øyvind A. Holm" <sunny@sunbase.org>
To: git@vger.kernel.org
Cc: jnareb@gmail.com, gitster@pobox.com,
	"Øyvind A. Holm" <sunny@sunbase.org>
Subject: [PATCH] gitweb: Remove "uninitialized value" Perl warning
Date: Tue, 12 Jan 2016 04:31:56 +0100	[thread overview]
Message-ID: <1452569516-25657-1-git-send-email-sunny@sunbase.org> (raw)

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

             reply	other threads:[~2016-01-12  3:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-12  3:31 Øyvind A. Holm [this message]
     [not found] ` <xmqq4meitsce.fsf@gitster.mtv.corp.google.com>
2016-01-12 21:20   ` [PATCH] gitweb: Remove "uninitialized value" Perl warning Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1452569516-25657-1-git-send-email-sunny@sunbase.org \
    --to=sunny@sunbase.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=jnareb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).