git/list[1] front-page[2] threads[3] people[4] search[5] about
 

PATCH] gitweb: Fix warnings when PATH_INFO is empty

From
Jakub Narebski <jnareb@gmail.com>
Date
Sep 17, 2006, 12:09 UTC
Message-ID
<200609171409.44958.jnareb@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 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
Message 1 of 1 in “PATCH] gitweb: Fix warnings when PATH_INFO is empty”
  1. Jakub NarebskiSep 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.