Subject: PATCH] gitweb: Fix warnings when PATH_INFO is empty

From: Jakub Narebski <[email-masked]>
Date: Sun, 17 Sep 2006 14:09:44 +0200

Signed-off-by: Jakub Narebski <[email-masked]>
---
 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