Skip to contentSkip to conversation

commit:fix use of uninitialized value [...] in server log

PATCH New Raphaël Gertz via GitGitGadget 1 participant 1 message Apr 25, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 commit:fix use of uninitialized value [...] in server log

From: =?UTF-8?q?Rapha=C3=ABl=20Gertz?= <[email protected]>

This change fix the message about uninitialized value when trying to access undefined hash indexes.

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

Add myself as warning fix author.

---
gitweb: fix tests on uninitialized hash indexes to avoid uninitialized value warnings in server log

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

Raphaël Gertz: 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(-)

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-617%2Frapsys%2Fmaint-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-617/rapsys/maint-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/617

 gitweb/README      | 3 +++
 gitweb/gitweb.perl | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
gitweb/README +3 -0
index 471dcfb691b..8964478a3fc 100644
@@ -66,5 +66,8 @@ AUTHORS
 Originally written by:
   Kay Sievers <[email protected]>
 
+Perl warning fix:
+  Raphaël Gertz <[email protected]>
+
 Any comment/question/concern to:
   Git mailing list <[email protected]>
gitweb/gitweb.perl +2 -2
index 65a3a9e62e8..76e71259824 100755
@@ -1406,7 +1406,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
@@ -5998,7 +5998,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");
 

base-commit: af6b65d45ef179ed52087e80cb089f6b2349f4ec

Signature · 1 line
gitgitgadget