[PATCH] gitweb: fix warnings from dd70235f5a81e (PATH_INFO)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



And removed if in if where one if is enough.
---
Martin Waitz <tali@xxxxxxxxxxxxxx> wrote:
> +	if (defined $project) {
> +		$project = undef unless $project;
> +	}
This is an if in an if, one if is enough.

> +	if ($path_info =~ m,^$project/([^/]+)/(.+)$,) {
Warning if $project is undef.
> +	} elsif ($path_info =~ m,^$project/([^/]+)$,) {
The same.
> +$git_dir = "$projectroot/$project";
The same.

We really need a gitweb test target.

Something else I noted:
> +	while ($project && !-e "$projectroot/$project/HEAD") {
Evaluating $project boolean value leads to problems if a repository is
named "0" (I dunno if there are other strings than "" and "0" which
evaluate to false in perl).  There are multiple places where this is
used so I did not change it in this patch (even added one more).
Should this be changed?
---
 gitweb/gitweb.perl |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 346c15c..4d39525 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -281,22 +281,20 @@ if (validate_input($path_info) && !defin
 	while ($project && !-e "$projectroot/$project/HEAD") {
 		$project =~ s,/*[^/]*$,,;
 	}
-	if (defined $project) {
-		$project = undef unless $project;
-	}
-	if ($path_info =~ m,^$project/([^/]+)/(.+)$,) {
+	$project = undef if !$project;
+	if ($project && $path_info =~ m,^$project/([^/]+)/(.+)$,) {
 		# we got "project.git/branch/filename"
 		$action    ||= "blob_plain";
 		$hash_base ||= $1;
 		$file_name ||= $2;
-	} elsif ($path_info =~ m,^$project/([^/]+)$,) {
+	} elsif ($project && $path_info =~ m,^$project/([^/]+)$,) {
 		# we got "project.git/branch"
 		$action ||= "shortlog";
 		$hash   ||= $1;
 	}
 }
 
-$git_dir = "$projectroot/$project";
+$git_dir = "$projectroot/$project" if $project;
 
 # dispatch
 my %actions = (
-- 
1.4.2.1.ge767

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]