# git-http-backend vs gitweb pathinfo mode

2 messages from 2013-08-05 to 2013-08-05. Participants: Tony Finch.
Thread: https://gitlist.dev/t/34613

## Tony Finch, 2013-08-05 15:34

Subject: git-http-backend vs gitweb pathinfo mode
Message-ID: <alpine.LSU.2.00.1308051624570.16837@hermes-2.csi.cam.ac.uk>
URL: https://gitlist.dev/e/alpine.LSU.2.00.1308051624570.16837%40hermes-2.csi.cam.ac.uk

```
Background:

You cam make the same URL work for gitwe and git clone as described in
git-http-backend(1). It says:

   To serve gitweb at the same url, use a ScriptAliasMatch to only
   those URLs that git http-backend can handle, and forward the rest
   to gitweb:

       ScriptAliasMatch \
               "(?x)^/git/(.*/(HEAD | \
                               info/refs | \
                               objects/(info/[^/]+ | \
                                        [0-9a-f]{2}/[0-9a-f]{38} | \
                                        pack/pack-[0-9a-f]{40}\.(pack|idx)) | \
                               git-(upload|receive)-pack))$" \
               /usr/libexec/git-core/git-http-backend/$1

       ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/

Gitweb has a friendly URL mode that uses pathinfo instead of query
parameters.

Problem:

In pathinfo mode, gitweb sometimes produces URLs ending in /HEAD which
match the git-http-backend regex and therefore get passed to the wrong
CGI.

For example, go to https://git.csx.cam.ac.uk/i/ucs/git/git.git/tree
and click on the gitweb subdirectory which takes you to
https://git.csx.cam.ac.uk/i/ucs/git/git.git/tree/HEAD:/gitweb
then click on [git/git.git] to go back, which takes you to
https://git.csx.cam.ac.uk/i/ucs/git/git.git/tree/HEAD

Half-arsed solution:

I have amended the regex to start like

               "(?x)^/git/(.*/((?<=[.]git/)HEAD | \

which solves the problem for me since all my repos have names ending in
.git and this doesn't clash with any gitweb action names. I don't think
this is a general solution because some people like bare extensionless
repo names. On the other hand I don't think the regex should list all the
dozens of gitweb action names. So I'm not sure what the best fix is.

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.

```

## Tony Finch, 2013-08-05 15:51

Subject: Re: git-http-backend vs gitweb pathinfo mode
Message-ID: <alpine.LSU.2.00.1308051650090.16837@hermes-2.csi.cam.ac.uk>
URL: https://gitlist.dev/e/alpine.LSU.2.00.1308051650090.16837%40hermes-2.csi.cam.ac.uk
In-Reply-To: <alpine.LSU.2.00.1308051624570.16837@hermes-2.csi.cam.ac.uk>

```
Tony Finch <dot@dotat.at> wrote:
>
> For example, go to https://git.csx.cam.ac.uk/i/ucs/git/git.git/tree
> and click on the gitweb subdirectory which takes you to
> https://git.csx.cam.ac.uk/i/ucs/git/git.git/tree/HEAD:/gitweb
> then click on [git/git.git] to go back, which takes you to
> https://git.csx.cam.ac.uk/i/ucs/git/git.git/tree/HEAD

Whoops, those are the internal not the external URLs... try:

   https://git.csx.cam.ac.uk/x/ucs/git/git.git/tree
-> https://git.csx.cam.ac.uk/x/ucs/git/git.git/tree/HEAD:/gitweb
-> https://git.csx.cam.ac.uk/x/ucs/git/git.git/tree/HEAD

Tony.
-- 
f.anthony.n.finch  <dot@dotat.at>  http://dotat.at/
Forties, Cromarty: East, veering southeast, 4 or 5, occasionally 6 at first.
Rough, becoming slight or moderate. Showers, rain at first. Moderate or good,
occasionally poor at first.

```
