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

Re: What's cooking in git.git (Jan 2012, #08; Tue, 31)

From
Junio C Hamano <gitster@pobox.com>
Date
Feb 1, 2012, 20:46 UTC
Message-ID
<7vty3a2sf7.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7v39au47dt.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 29 quoted lines
> I am getting 
>
>     7ad1b64084ff003f71fe749a3e5a74d071a193d8 is the first bad commit
>     commit 7ad1b64084ff003f71fe749a3e5a74d071a193d8
>     Author: Bernhard R. Link <brl+git@mail.brlink.eu>
>     Date:   Mon Jan 30 21:05:47 2012 +0100
>
>         gitweb: move hard coded .git suffix out of git_get_projects_list
>
> *** t9502-gitweb-standalone-parse-output.sh ***
> ...
> not ok - 14 forks: "forks" action for forked repository
> #
> #               gitweb_run "p=foo.git;a=forks" &&
> #               grep -q ">foo/foo-forked\\.git<" gitweb.body &&
> #               grep -q ">fork of foo<"          gitweb.body
> #
> ok 15 - forks: can access forked repository
> ok 16 - forks: project_index lists all projects (incl. forks)
> # failed 1 among 16 test(s)
>
> The output file gitweb.body has this in it:
>
> <div class="page_body">
> <br /><br />
> 404 - No forks found
> <br />
> </div>
> <div class="page_footer">
And of course the culprit turns out to be that "cute" expression.
-- >8 --
Subject: gitweb: do not use assignment with regexp replace in parameter

A recent patch made the code to generate a parameter to git_get_projects_list a bit too cute, by introducing a new variable, assigning a value to it, and then munging that value with s/// replacement, all in the parameter list.

The whole expression returns the number of replacements, not the resulting value in the variable after s/// operation.

Split them into separate expressions, which also would make the resulting lines shorter and less taxing on the brain.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 gitweb/gitweb.perl |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b764d51..e074cd7 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -6003,7 +6003,9 @@ sub git_forks {
 		die_error(400, "Unknown order parameter");
 	}
 
-	my @list = git_get_projects_list((my $filter = $project) =~ s/\.git$//);
+	my $filter = $project;
+	$filter =~ s/\.git$//;
+	my @list = git_get_projects_list($filter);
 	if (!@list) {
 		die_error(404, "No forks found");
 	}
@@ -6062,7 +6064,9 @@ sub git_summary {
 
 	if ($check_forks) {
 		# find forks of a project
-		@forklist = git_get_projects_list((my $filter = $project) =~ s/\.git$//);
+		my $filter = $project;
+		$filter =~ s/\.git$//;
+		@forklist = git_get_projects_list($filter);
 		# filter out forks of forks
 		@forklist = filter_forks_from_projects_list(\@forklist)
 			if (@forklist);
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 9 in “What's cooking in git.git (Jan 2012, #08; Tue, 31)”
  1. Junio C HamanoFeb 1, 2012
  2. Jakub NarebskiFeb 1, 2012
  3. Junio C HamanoFeb 1, 2012
  4. Junio C HamanoFeb 1, 2012
  5. Junio C HamanoFeb 2, 2012
  6. Junio C HamanoFeb 10, 2012
  7. Junio C HamanoFeb 10, 2012
  8. Nguyen Thai Ngoc DuyFeb 10, 2012
  9. Junio C HamanoFeb 10, 2012

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.