threads / patch / 15386

patchavoid gitweb uninitialized value warning

Subject: [PATCH] avoid gitweb uninitialized value warning

## tl;dr

2 messages between Sep 5, 2008 and Sep 18, 2008. Diffs are folded; open one to read it.

replies: 1people: 2as markdown or json

Joey Hess· Sep 5, 2008, 18:26 UTC · lore

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

Signed-off-by: Joey Hess <joey@kitenet.net>
---
 gitweb/gitweb.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Show changes to gitweb/gitweb.perl +1 −1
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 29e2156..da474d0 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -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
-- 
1.5.6.5

-- 
see shy jo
Jakub Narebski· Sep 18, 2008, 15:13 UTC · re: Joey Hess · lore

Re: [PATCH] avoid gitweb uninitialized value warning

Joey Hess <joey@kitenet.net> writes:
> 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
>
> In the ususual case when there is no commit message, gitweb would
> output an uninitialized value warning.
Typo: s/ususual/unusual/
> 
> Signed-off-by: Joey Hess <joey@kitenet.net>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Show 14 quoted lines
> ---
>  gitweb/gitweb.perl |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index 29e2156..da474d0 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -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 "") {
Show 8 quoted lines
>  		$co{'title'} = $co{'title_short'} = '(no commit message)';
>  	}
>  	# remove added spaces
> -- 
> 1.5.6.5
> 
> -- 
> see shy jo
-- 
Jakub Narebski
Poland
ShadeHawk on #git

← back to recent threads