Skip to contentSkip to conversation

avoid gitweb uninitialized value warning

PATCH In review Joey Hess 2 participants 2 messages Jun 15, 2016

lore
Share & tools
lore

Joey Hess

author
#0 lore raw

PATCH 1/1 avoid gitweb uninitialized value warning

In the ususual case when there is no commit message, gitweb would output an uninitialized value warning.

---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +1 -1
index 29e2156..da474d0 100755
@@ -2123,7 +2123,7 @@ sub parse_commit_text {
 			last;
 		}
 	}
-	if ($co{'title'} eq "") {
+	if (! defined $co{'title'} || $co{'title'} eq "") {
 		$co{'title'} = $co{'title_short'} = '(no commit message)';
 	}
 	# remove added spaces
Signature · 4 lines
1.5.6.5

-- 
see shy jo
Acked-by on v1 1/1
#1 lore raw
Quoted 1 line · Joey Hess

Subject: [PATCH] avoid gitweb uninitialized value warning

I would say _where_ this uninitialized value warning was, e.g.

Subject: [PATCH] gitweb: avoid warnings for commits with no body

Quoted 3 lines

In the ususual case when there is no commit message, gitweb would output an uninitialized value warning.

Typo: s/ususual/unusual/

Quoted 2 lines
Quoted 9 lines
---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
gitweb/gitweb.perl +0 -0
index 29e2156..da474d0 100755

gitweb/gitweb.perl sub parse_commit_text { · line 2126

Quoted 5 lines
gitweb/gitweb.perl +1 -1
@@ -2123,7 +2123,7 @@ sub parse_commit_text {
 			last;
 		}
 	}
-	if ($co{'title'} eq "") {
+	if (! defined $co{'title'} || $co{'title'} eq "") {

I would avoid space between logical negation operator '!' and its operand, i.e. I would write:

+ if (!defined $co{'title'} || $co{'title'} eq "") {

Quoted 8 lines
gitweb/gitweb.perl +0 -0
 		$co{'title'} = $co{'title_short'} = '(no commit message)';
 	}
 	# remove added spaces
Signature · 4 lines
1.5.6.5

-- 
see shy jo
Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git