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

5 messages from 2007-06-28 to 2007-07-09. Participants: Matt McCutchen, Junio C Hamano, Luben Tuikov.
Thread: https://gitlist.dev/t/8764

## Matt McCutchen, 2007-06-28 18:57

Subject: [PATCH] gitweb: make search form generate pathinfo-style URLs
Message-ID: <1183057027.6108.4.camel@mattlaptop2>
URL: https://gitlist.dev/e/1183057027.6108.4.camel%40mattlaptop2

```
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") .
 		      $cgi->hidden(-name => "a") . "\n" .
 		      $cgi->hidden(-name => "h") . "\n" .
 		      $cgi->popup_menu(-name => 'st', -default => 'commit',
-- 
1.5.2.2.552.gc32f

```

## Matt McCutchen, 2007-07-02 19:03

Subject: Re: [PATCH] gitweb: make search form generate pathinfo-style URLs
Message-ID: <1183402981.2664.10.camel@mattlaptop2>
URL: https://gitlist.dev/e/1183402981.2664.10.camel%40mattlaptop2
In-Reply-To: <1183057027.6108.4.camel@mattlaptop2>

```
On Thu, 2007-06-28 at 14:57 -0400, Matt McCutchen wrote:
> 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.

I sent this patch four days ago but no one has commented or done
anything about it.  Please clue me in: is this typical, or did I do
something wrong or do I need to do something else?

Thanks,
Matt

```

## Junio C Hamano, 2007-07-02 23:11

Subject: Re: [PATCH] gitweb: make search form generate pathinfo-style URLs
Message-ID: <7vfy46wgdg.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vfy46wgdg.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <1183402981.2664.10.camel@mattlaptop2>

```
Matt McCutchen <hashproduct@gmail.com> writes:

> I sent this patch four days ago but no one has commented or done
> anything about it.  Please clue me in: is this typical, or did I do
> something wrong or do I need to do something else?

Yes, it sometimes happens to patches to some areas.  No, you did
not do anything wrong as far as I can see.  Yes, sending this
kind of reminder out is exactly what is needed.

I have three recent patches from you on gitweb in my patch
queue.

  Subject: [PATCH] gitweb: snapshot cleanups & support for offering multiple
          formats
  Date: Thu, 28 Jun 2007 14:02:13 -0400
  Message-ID: <1183053733.6108.0.camel@mattlaptop2>

  Subject: [PATCH] gitweb: make search form generate pathinfo-style URLs
  Date: Thu, 28 Jun 2007 14:57:07 -0400
  Message-ID: <1183057027.6108.4.camel@mattlaptop2>

  Subject: [PATCH] gitweb: make "No commits" in project list gray, not bold
          green
  Date: Thu, 28 Jun 2007 18:15:22 -0400
  Message-ID: <1183068922.6108.8.camel@mattlaptop2>

There are people whom I consider "gitweb folks", who are more
familiar with, and more importantly who are more interested in,
gitweb than I am.  Having good "subsystem people" makes gitweb a
lower-priority area to myself, and for these patches it made
even so that nobody commented on them.

I should have asked Ack/Nack/Comments from gitweb folks much
earlier, but was a bit too loaded with the day job.  Sorry about
that.

So, gitweb folks, what do you think about these patches?

```

## Junio C Hamano, 2007-07-07 21:01

Subject: Re: [PATCH] gitweb: make search form generate pathinfo-style URLs
Message-ID: <7vejjk6i96.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7vejjk6i96.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <1183057027.6108.4.camel@mattlaptop2>

```
Matt McCutchen <hashproduct@gmail.com> writes:

> 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.

```

## Luben Tuikov, 2007-07-09 19:03

Subject: Re: [PATCH] gitweb: make search form generate pathinfo-style URLs
Message-ID: <272578.10203.qm@web31813.mail.mud.yahoo.com>
URL: https://gitlist.dev/e/272578.10203.qm%40web31813.mail.mud.yahoo.com
In-Reply-To: <7vejjk6i96.fsf@assigned-by-dhcp.cox.net>

```
--- Junio C Hamano <gitster@pobox.com> wrote:

> Matt McCutchen <hashproduct@gmail.com> writes:
> 
> > 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.

Good catch.

    Luben

```
