PATCH] gitweb: Fix warnings when PATH_INFO is empty

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

 



Signed-off-by: Jakub Narebski <jnareb@xxxxxxxxx>
---
 gitweb/gitweb.perl |   44 +++++++++++++++++++++++---------------------
 1 files changed, 23 insertions(+), 21 deletions(-)

diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 1549f5f..689528e 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -274,29 +274,31 @@ if (defined $searchtext) {
 
 # now read PATH_INFO and use it as alternative to parameters
 our $path_info = $ENV{"PATH_INFO"};
-$path_info =~ s|^/||;
-$path_info =~ s|/$||;
-if (validate_input($path_info) && !defined $project) {
-	$project = $path_info;
-	while ($project && !-e "$projectroot/$project/HEAD") {
-		$project =~ s,/*[^/]*$,,;
-	}
-	if (defined $project) {
-		$project = undef unless $project;
-	}
-	if ($path_info =~ m,^$project/([^/]+)/(.+)$,) {
-		# we got "project.git/branch/filename"
-		$action    ||= "blob_plain";
-		$hash_base ||= $1;
-		$file_name ||= $2;
-	} elsif ($path_info =~ m,^$project/([^/]+)$,) {
-		# we got "project.git/branch"
-		$action ||= "shortlog";
-		$hash   ||= $1;
+if ($path_info) {
+	$path_info =~ s|^/||;
+	$path_info =~ s|/$||;
+	if (validate_input($path_info) && !defined $project) {
+		$project = $path_info;
+		while ($project && !-e "$projectroot/$project/HEAD") {
+			$project =~ s,/*[^/]*$,,;
+		}
+		if (defined $project) {
+			$project = undef unless $project;
+		}
+		if ($path_info =~ m,^$project/([^/]+)/(.+)$,) {
+			# we got "project.git/branch/filename"
+			$action    ||= "blob_plain";
+			$hash_base ||= $1;
+			$file_name ||= $2;
+		} elsif ($path_info =~ m,^$project/([^/]+)$,) {
+			# we got "project.git/branch"
+			$action ||= "shortlog";
+			$hash   ||= $1;
+		}
 	}
-}
 
-$git_dir = "$projectroot/$project";
+	$git_dir = "$projectroot/$project";
+}
 
 # dispatch
 my %actions = (
-- 
1.4.2.1

-
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]