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

Re: [PATCH] gitweb: make search form generate pathinfo-style URLs

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 7, 2007, 21:01 UTC
Message-ID
<7vejjk6i96.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<1183057027.6108.4.camel@mattlaptop2>
Matt McCutchen <hashproduct@gmail.com> writes:
Show 32 quoted lines
> The search form generated traditional-style URLs with a "p=" parameter
> even when the pathinfo feature was on.  This patch makes it generate
> pathinfo-style URLs when appropriate.
>
> Signed-off-by: Matt McCutchen <hashproduct@gmail.com>
> ---
>  gitweb/gitweb.perl |   12 +++++++++---
>  1 files changed, 9 insertions(+), 3 deletions(-)
>
> diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> index f36428e..7b0e110 100755
> --- a/gitweb/gitweb.perl
> +++ b/gitweb/gitweb.perl
> @@ -2215,12 +2215,18 @@ EOF
>  		} else {
>  			$search_hash = "HEAD";
>  		}
> +		my $action = $my_uri;
> +		my ($use_pathinfo) = gitweb_check_feature('pathinfo');
> +		if ($use_pathinfo) {
> +			$action .= "/$project";
> +		} else {
> +			$cgi->param("p", $project);
> +		}
>  		$cgi->param("a", "search");
>  		$cgi->param("h", $search_hash);
> -		$cgi->param("p", $project);
> -		print $cgi->startform(-method => "get", -action => $my_uri) .
> +		print $cgi->startform(-method => "get", -action => $action) .
>  		      "<div class=\"search\">\n" .
> -		      $cgi->hidden(-name => "p") . "\n" .
> +		      (!$use_pathinfo && $cgi->hidden(-name => "p") . "\n") .

Ahhhhh. (!$use_pathinfo && blah) when $use_pathinfo is true evaluates to an empty string, which saves you from protecting yourself from undef. Perhaps clever, but is not terribly nice.

Other than that, the patch looks sane to me.
Previous: Junio C HamanoNext: Luben Tuikov
Message 4 of 5 in “gitweb: make search form generate pathinfo-style URLs”
  1. gitweb: make search form generate pathinfo-style URLsMatt McCutchen, Jun 28, 2007
  2. Matt McCutchenJul 2, 2007
  3. Junio C HamanoJul 2, 2007
  4. Junio C HamanoJul 7, 2007
  5. Luben TuikovJul 9, 2007

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.