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

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

From
MLMatthias Lederhofer <matled@gmx.net>
Date
Sep 17, 2006, 12:14 UTC
Message-ID
<20060917121408.GA19860@moooo.ath.cx>
In-Reply-To
<20060916210832.GV17042@admingilde.org>

And removed if in if where one if is enough. --- Martin Waitz <tali@admingilde.org> 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
Previous: Jakub NarebskiNext: Junio C Hamano
Message 3 of 8 in “gitweb: more support for PATH_INFO based URLs”
  1. gitweb: more support for PATH_INFO based URLsMartin Waitz, Sep 16, 2006
  2. Jakub NarebskiSep 16, 2006
  3. gitweb: fix warnings from dd70235f5a81e (PATH_INFO)Matthias Lederhofer, Sep 17, 2006
  4. Junio C HamanoSep 17, 2006
  5. Jakub NarebskiSep 17, 2006
  6. Jakub NarebskiSep 17, 2006
  7. Martin WaitzSep 19, 2006
  8. Jakub NarebskiSep 19, 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.