git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* gitweb:fix tests on uninitialized hash indexes to avoid uninitialized value warnings in server log
@ 2020-04-24 21:59 Raphaël Gertz
  0 siblings, 0 replies; only message in thread
From: Raphaël Gertz @ 2020-04-24 21:59 UTC (permalink / raw)
  To: git

[-- Attachment #1: Type: text/plain, Size: 1190 bytes --]

Hi,

It's happened that I tried to solve lots of meaningless warnings
in web server error log.

I think it makes no sense to spam error log with warnings about
uninitialized value when trying to run careless tests on undefined
hash indexes.

This is a simple fix that I did long ago that check carefully the
index before running tests on it.

I added myself as warning fix author as well.

My goal is to avoid re-applying the patch on each distribution update.

The warning message fixed in web server error log :
Use of uninitialized value $params{"action"} in string eq at gitweb.cgi
line 1377

Pull request was done here against "maint" branch :
https://github.com/gitgitgadget/git/pull/617

Pull request was done here against "master" branch if required :
https://github.com/git/git/pull/767

The change patch is attached if required.

May you plz merge my change ?

Best regards

Raphaël Gertz <git@rapsys.eu>:
  gitweb/README: add myself as warning fix author
  gitweb/gitweb.perl: fix careless test on undefined hash indexes

  gitweb/README      | 3 +++
  gitweb/gitweb.perl | 4 ++--
  2 files changed, 5 insertions(+), 2 deletions(-)

Signed-off-by: Raphaël Gertz <git@rapsys.eu>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: gitweb.cgi.rapsys.patch --]
[-- Type: text/x-diff; charset=us-ascii; name=gitweb.cgi.rapsys.patch, Size: 1377 bytes --]

diff -urNp gitweb/gitweb.perl.orig gitweb/gitweb.perl
--- gitweb/gitweb.perl.orig	2019-11-14 07:39:24.244704744 +0100
+++ gitweb/gitweb.perl	2019-11-14 07:33:50.641602829 +0100
@@ -1374,7 +1374,7 @@ sub href {
 
 		# since we destructively absorb parameters, we keep this
 		# boolean that remembers if we're handling a snapshot
-		my $is_snapshot = $params{'action'} eq 'snapshot';
+		my $is_snapshot = defined $params{'action'} && $params{'action'} eq 'snapshot';
 
 		# Summary just uses the project path URL, any other action is
 		# added to the URL
@@ -5959,7 +5959,7 @@ sub git_history_body {
 		      $cgi->a({-href => href(action=>$ftype, hash_base=>$commit, file_name=>$file_name)}, $ftype) . " | " .
 		      $cgi->a({-href => href(action=>"commitdiff", hash=>$commit)}, "commitdiff");
 
-		if ($ftype eq 'blob') {
+		if (defined $ftype && $ftype eq 'blob') {
 			print " | " .
 			      $cgi->a({-href => href(action=>"blob_plain", hash_base=>$commit, file_name=>$file_name)}, "raw");
 
diff -urNp gitweb/README.orig gitweb/README
--- gitweb/README.orig	2019-11-14 07:39:24.244704744 +0100
+++ gitweb/README	2019-11-14 07:33:50.641602829 +0100
@@ -66,5 +66,8 @@ AUTHORS
 Originally written by:
   Kay Sievers <kay.sievers@vrfy.org>
 
+Perl warning fix:
+  Raphaël Gertz <git@rapsys.eu>
+
 Any comment/question/concern to:
   Git mailing list <git@vger.kernel.org>

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-24 22:18 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-24 21:59 gitweb:fix tests on uninitialized hash indexes to avoid uninitialized value warnings in server log Raphaël Gertz

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).