Skip to contentSkip to conversation

Static gitweb content when using pathinfo

DISCUSSION José María Escartín Esteban 2 participants 6 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I'm running gitweb in a server.example.com/gitweb/ scenario. If I don't enable pathinfo everything works fine, but when I enable pathinfo the static content stops showing up in the browser.

I'm not an HTML or perl expert, but I think that this may be due to a missing slash in the construction of the base tag: Using the upstream script I am getting

<base href="http://server.example.com/gitweb" />

and no static content. Once I tune the script to add a final slash to the url

<base href="http://server.example.com/gitweb/" />

the static content shows up again.

Maybe I'm doing something wrong (am I?), and possibly this can be solved from the web server side, but maybe it also makes some sense to include in the script some check that the url used in the base tag ends with a slash. In that case, given my lack of perl skills, I would be really grateful if somebody implemented it.

Thank you for your attention.

Greetings,

	E.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk99pBMACgkQY+7weQMem3y28wCeOotCIgFF8sT4LKgq599IhB/E 0qcAn2dri0Z61PjV90bxfBG1QMFD3c75
=6PBz
-----END PGP SIGNATURE-----

#1 lore raw
Quoted 13 lines · José María Escartín Esteban

Hi,

I'm running gitweb in a server.example.com/gitweb/ scenario. If I don't enable pathinfo everything works fine, but when I enable pathinfo the static content stops showing up in the browser.

I'm not an HTML or perl expert, but I think that this may be due to a missing slash in the construction of the base tag: Using the upstream script I am getting

<base href="http://server.example.com/gitweb" />

and no static content. Once I tune the script to add a final slash to the url

Quoted 8 lines

<base href="http://server.example.com/gitweb/" />

the static content shows up again.

Maybe I'm doing something wrong (am I?), and possibly this can be solved from the web server side, but maybe it also makes some sense to include in the script some check that the url used in the base tag ends with a slash. In that case, given my lack of perl skills, I would be really grateful if somebody implemented it.

How do you deploy gitweb, what is your web server configuration, and what is the URL of main gitweb page (using placeholders like 'example.com' or 'foo')?

When I am running gitweb, it uses http://localhost/cgi-bin/gitweb/gitweb.cgi
URL, and BASE element for path_info is

<base href="http://localhost/cgi-bin/gitweb/gitweb.cgi" />

Note that last component of 'href' attribute of base element is the basename of script, which according to HTML 4.01[1] and RFC 3986[2] is removed[3]

o return a string consisting of the reference's path component appended to all but the last segment of the base URI's path (i.e., excluding any characters after the right-most "/" in the base URI path, or excluding the entire base URI path if it does not contain any "/" characters).

There might be problem if you configured your web server to serve gitweb using it as a handler for subdirectory, so the script name does not need to appear in URL, e.g.

http://localhost/cgi-bin/gitweb

which would require the following base element

<base href="http://localhost/cgi-bin/gitweb/" />

Gitweb would have to distinguish those two cases somehow, and either add or not add trailing slash '/'.

[1]: http://www.w3.org/TR/html401/struct/links.html#h-12.4
[2]: http://tools.ietf.org/html/rfc3986#section-5.2
[3]: http://tools.ietf.org/html/rfc3986#section-5.2.3

Quoted 5 lines

Once I tune the script to add a final slash to the url

<base href="http://server.example.com/gitweb/" />

the static content shows up again.

By "tune the script" do you mean editing gitweb.cgi, or adding setting $base_url to gitweb configuration file, see gitweb.conf(5):

$base_url
Base URL for relative URLs in pages generated by gitweb, (e.g. $logo, $favicon, @stylesheets if they are relative URLs), needed and used <base href="$base_url"> only for URLs with nonempty PATH_INFO. Usually gitweb sets its value correctly, and there is no need to set this variable, e.g. to $my_uri or "/". See $per_request_config if you need to override it anyway.

You can e.g. put

  $base_url .= '/' unless ($base_url =~ m!/$!);

in the gitweb configuration file to ensure that it ends with '/', whatever it is.

HTH

Signature · 2 lines
Jakub Narebski
Poland
#2 lore raw
Quoted 14 lines · Jakub Narebski
Quoted 13 lines · José María Escartín Esteban

Hi,

I'm running gitweb in a server.example.com/gitweb/ scenario. If I don't enable pathinfo everything works fine, but when I enable pathinfo the static content stops showing up in the browser.

I'm not an HTML or perl expert, but I think that this may be due to a missing slash in the construction of the base tag: Using the upstream script I am getting

<base href="http://server.example.com/gitweb" />

and no static content. Once I tune the script to add a final slash to the url

Quoted 7 lines
Quoted 3 lines

<base href="http://server.example.com/gitweb/" />

the static content shows up again.

How do you deploy gitweb, what is your web server configuration, and what is the URL of main gitweb page (using placeholders like 'example.com' or 'foo')?

Ping?

[...]

Quoted 9 lines

There might be problem if you configured your web server to serve gitweb using it as a handler for subdirectory, so the script name does not need to appear in URL, e.g.

http://localhost/cgi-bin/gitweb

which would require the following base element

<base href="http://localhost/cgi-bin/gitweb/" />

[...]

Quoted 17 lines
Quoted 5 lines

Once I tune the script to add a final slash to the url

<base href="http://server.example.com/gitweb/" />

the static content shows up again.

By "tune the script" do you mean editing gitweb.cgi, or adding setting $base_url to gitweb configuration file, see gitweb.conf(5):

$base_url
Base URL for relative URLs in pages generated by gitweb, (e.g. $logo, $favicon, @stylesheets if they are relative URLs), needed and used <base href="$base_url"> only for URLs with nonempty PATH_INFO. Usually gitweb sets its value correctly, and there is no need to set this variable, e.g. to $my_uri or "/". See $per_request_config if you need to override it anyway.

Quoted 6 lines

You can e.g. put

  $base_url .= '/' unless ($base_url =~ m!/$!);

in the gitweb configuration file to ensure that it ends with '/', whatever it is.

By the way, would the following proposed addition to gitweb.conf(5) manpage would help your situation?

-------- >8 ---------- >8 ---------
Subject: [PATCH/RFC] gitweb.conf(5): When to set $base_url

Add a paragraph to description of $base_url variable in gitweb.conf(5) manpage explaining when and why one might need to set it.

---
 Documentation/gitweb.conf.txt |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
Documentation/gitweb.conf.txt +14 -0
index 7aba497..a2a6ddf 100644
@@ -559,6 +559,20 @@ $base_url::
 	PATH_INFO.  Usually gitweb sets its value correctly,
 	and there is no need to set this variable, e.g. to $my_uri or "/".
 	See `$per_request_config` if you need to override it anyway.
++
+You would need to set this variable when using gitweb as a directory
+handler and using path_info-based URLs.  For example if your web
+server is set up in such way that full path to browse repositories is
+`http://git.example.com/gitweb` and static files are served from
+'/gitweb/static' directory with default values (e.g. `$logo` is
+`static/git-logo.png`), then you would need to set `$base_url` to
+(for example):
++
+----------------------------------------------------------------------
+our $base_url = "http://git.example.com/gitweb/";
+----------------------------------------------------------------------
++
+The trailing slash is required!
 
 
 CONFIGURING GITWEB FEATURES
Signature · 1 line
1.7.9
#3 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Thank you for your detailed answers, and sorry for the delay in my reply.

Quoted 19 lines · Jakub Narebski
Quoted 18 lines · Jakub Narebski
Quoted 16 lines · José María Escartín Esteban

Hi,

I'm running gitweb in a server.example.com/gitweb/ scenario. If I don't enable pathinfo everything works fine, but when I enable pathinfo the static content stops showing up in the browser.

I'm not an HTML or perl expert, but I think that this may be due to a missing slash in the construction of the base tag: Using the upstream script I am getting

<base href="http://server.example.com/gitweb" />

and no static content. Once I tune the script to add a final slash to the url

<base href="http://server.example.com/gitweb/" />

the static content shows up again.

Quoted 8 lines
Quoted 3 lines

How do you deploy gitweb, what is your web server configuration, and what is the URL of main gitweb page (using placeholders like 'example.com' or 'foo')?

Ping?

[...]

I'll describe the setup at the end of my email, but you already provided the solution!

Quoted 4 lines
Quoted 4 lines

There might be problem if you configured your web server to serve gitweb using it as a handler for subdirectory, so the script name does not need to appear in URL, e.g.

Quoted 8 lines
Quoted 5 lines

http://localhost/cgi-bin/gitweb

which would require the following base element

<base href="http://localhost/cgi-bin/gitweb/" />

[...]

Yes, that was precisely the problem.

Quoted 17 lines
Quoted 17 lines
Quoted 5 lines

Once I tune the script to add a final slash to the url

<base href="http://server.example.com/gitweb/" />

the static content shows up again.

By "tune the script" do you mean editing gitweb.cgi, or adding setting $base_url to gitweb configuration file, see gitweb.conf(5):

$base_url
Base URL for relative URLs in pages generated by gitweb, (e.g. $logo, $favicon, @stylesheets if they are relative URLs), needed and used <base href="$base_url"> only for URLs with nonempty PATH_INFO. Usually gitweb sets its value correctly, and there is no need to set this variable, e.g. to $my_uri or "/". See $per_request_config if you need to override it anyway.

Quoted 7 lines
Quoted 6 lines

You can e.g. put

  $base_url .= '/' unless ($base_url =~ m!/$!);

in the gitweb configuration file to ensure that it ends with '/', whatever it is.

I was editing manually the gitweb.cgi script to add (always!) the slash. Your solution is of course better, and completely solves my problem.

Quoted 30 lines

By the way, would the following proposed addition to gitweb.conf(5) manpage would help your situation?

-------- >8 ---------- >8 ---------
Subject: [PATCH/RFC] gitweb.conf(5): When to set $base_url

Add a paragraph to description of $base_url variable in gitweb.conf(5) manpage explaining when and why one might need to set it.

---
 Documentation/gitweb.conf.txt |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
Documentation/gitweb.conf.txt +7 -0
index 7aba497..a2a6ddf 100644
@@ -559,6 +559,20 @@ $base_url::
 	PATH_INFO.  Usually gitweb sets its value correctly,
 	and there is no need to set this variable, e.g. to $my_uri or "/".
 	See `$per_request_config` if you need to override it anyway.
++
+You would need to set this variable when using gitweb as a directory
+handler and using path_info-based URLs.  For example if your web
+server is set up in such way that full path to browse repositories is
+`http://git.example.com/gitweb` and static files are served from
+'/gitweb/static' directory with default values (e.g. `$logo` is
+`static/git-logo.png`), then you would need to set `$base_url` to

Documentation/gitweb.conf.txt $base_url:: · line 578

Quoted 10 lines
Documentation/gitweb.conf.txt +7 -0
+(for example):
++
+----------------------------------------------------------------------
+our $base_url = "http://git.example.com/gitweb/";
+----------------------------------------------------------------------
++
+The trailing slash is required!
 
 
 CONFIGURING GITWEB FEATURES

This addition to the man page would of course have been useful, since it took me a while to detect that the problem was a missing slash in the base url. However, it would not have solved completely my problem, and for me the best has been to add the line of code you proposed in the previous email.

I am running a Debian testing (wheezy) server, so the distro gitweb files are:

	/etc/apache2/conf.d/gitweb
	/etc/gitweb.conf
	/usr/share/gitweb/gitweb.cgi
	/usr/share/gitweb/index.cgi -> /usr/share/gitweb/gitweb.cgi
	/usr/share/gitweb/static/*

I am using two sets of git repositories, and each of the sets works through a particular gitolite user:

	user     home
	----------------------
	git      /srv/project
	mygit    /srv/mygit

I wanted that different groups of people were able to browse the 'project' repos (in fact it is a mirror from the main project server) from
http://server.example.com/project/ ,
and the 'mygit' repos from
http://server.example.com/mygit/ .
And I wanted to keep urls as short and easy as possible, and to avoid proliferation of configs as much as possible.

The setup I came up with was to link

	/srv/www/project -> /usr/share/gitweb
	/srv/www/mygit -> /usr/share/gitweb

and to use the following configuration files:

######### /etc/apache2/conf.d/gitweb ################## <Directory /srv/www/project>

        SetEnv  GITWEB_PROJECTROOT      /srv/git/
        SetEnv  GITWEB_CONFIG           /etc/gitweb.conf

<IfModule mod_authn_file.c>
AuthType Basic
AuthName "Project gitweb" AuthUserFile /srv/htpwd/git-htpasswd
</IfModule>
Require valid-user
Order allow,deny
Allow from 123.123.123.123
Satisfy Any
Options FollowSymLinks +ExecCGI AddHandler cgi-script .cgi RewriteEngine On
RewriteBase /project/
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.* /project/index.cgi/$0 [L,PT]
</Directory>

<Directory /srv/www/mygit>

        SetEnv  GITWEB_PROJECTROOT      /srv/mygit/
        SetEnv  GITWEB_CONFIG           /etc/gitweb.conf

<IfModule mod_authn_file.c>
AuthType Basic
AuthName "My gitweb" AuthUserFile /srv/htpwd/mygit-htpasswd
</IfModule>
Require valid-user
Order allow,deny
Allow from 213.213.213.213
Satisfy Any
Options FollowSymLinks +ExecCGI AddHandler cgi-script .cgi RewriteEngine On
RewriteBase /mygit/
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule ^.* /mygit/index.cgi/$0 [L,PT]
</Directory>
#######################################################

######### /etc/gitweb.conf ############################ $projectroot = $ENV{'GITWEB_PROJECTROOT'}."repositories"; $git_temp = "/tmp";
$projects_list = $ENV{'GITWEB_PROJECTROOT'}."projects.list"; @diff_opts = ();
$feature{'pathinfo'}{'default'} = [1]; $feature{'highlight'}{'default'} = [1]; $projects_list_description_width = 50;
#######################################################

Probably there are better ways to implement this, but at least this seems to work, once I have added

	$base_url .= '/' unless ($base_url =~ m!/$!);

to /etc/gitweb.conf .

Greetings, and thanks again,

	E.

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAk+MOEsACgkQY+7weQMem3w4NwCfYHyX+vtap/HvV7/8CTYu42W2 AbEAoLi2868tD6LGoFdisiplWf9vSdRx
=RAme
-----END PGP SIGNATURE-----

#4 lore raw
Quoted 10 lines · José María Escartín Esteban
Quoted 9 lines · Jakub Narebski
Quoted 8 lines · Jakub Narebski

On Thu, 5 Apr 2012, José María Escartín Esteban wrote:

There might be problem if you configured your web server to serve gitweb using it as a handler for subdirectory, so the script name does not need to appear in URL, e.g.

http://localhost/cgi-bin/gitweb

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

which would require the following base element

<base href="http://localhost/cgi-bin/gitweb/" />

[...]

Yes, that was precisely the problem.

Note that you won't have problem with http://localhost as base url (without any directory), or in more realistic case using virtual host rather than virtual directory. The problem is that without '/' the path part of $base_url is stripped of last element.

Just for completeness.

[...]

Quoted 4 lines

This addition to the man page would of course have been useful, since it took me a while to detect that the problem was a missing slash in the base url. However, it would not have solved completely my problem, and for me the best has been to add the line of code you proposed in the previous email.

So how about the proposed updated addition at the end of this email?

Quoted 16 lines

I am running a Debian testing (wheezy) server, so the distro gitweb files are:

	/etc/apache2/conf.d/gitweb
	/etc/gitweb.conf
	/usr/share/gitweb/gitweb.cgi
	/usr/share/gitweb/index.cgi -> /usr/share/gitweb/gitweb.cgi
	/usr/share/gitweb/static/*

I am using two sets of git repositories, and each of the sets works through a particular gitolite user:

	user     home
	----------------------
	git      /srv/project
	mygit    /srv/mygit
Quoted 7 lines

I wanted that different groups of people were able to browse the 'project' repos (in fact it is a mirror from the main project server) from
http://server.example.com/project/ ,
and the 'mygit' repos from
http://server.example.com/mygit/ .
And I wanted to keep urls as short and easy as possible, and to avoid proliferation of configs as much as possible.

I think that is this "two sets" that created configuration with a problem.

Quoted 11 lines

The setup I came up with was to link

	/srv/www/project -> /usr/share/gitweb
	/srv/www/mygit -> /usr/share/gitweb

and to use the following configuration files:

######### /etc/apache2/conf.d/gitweb ################## <Directory /srv/www/project>

        SetEnv  GITWEB_PROJECTROOT      /srv/git/
        SetEnv  GITWEB_CONFIG           /etc/gitweb.conf

[...]

Quoted 11 lines

#######################################################

######### /etc/gitweb.conf ############################ $projectroot = $ENV{'GITWEB_PROJECTROOT'}."repositories"; $git_temp = "/tmp";
$projects_list = $ENV{'GITWEB_PROJECTROOT'}."projects.list"; @diff_opts = ();
$feature{'pathinfo'}{'default'} = [1]; $feature{'highlight'}{'default'} = [1]; $projects_list_description_width = 50;
#######################################################

A question: why not have

SetEnv GITWEB_PROJECTROOT /srv/git

and use

  $projectroot = "$ENV{'GITWEB_PROJECTROOT'}/repositories";
  $projects_list = "$ENV{'GITWEB_PROJECTROOT'}/projects.list";

BTW. what is this $git_temp? Is it modified gitweb, because core one doesn't need to use temporary directory for anything nowadays?

A tip: you can use GITWEB_CONFIG_COMMON for the common part of configuration and separate GITWEB_CONFIG for per-instance configuration. Though I am not sure if it would help in your case. It requires modern gitweb. though.

Quoted 6 lines

Probably there are better ways to implement this, but at least this seems to work, once I have added

	$base_url .= '/' unless ($base_url =~ m!/$!);

to /etc/gitweb.conf .

-- >8 ---------- >8 --
Subject: [PATCH] gitweb.conf(5): When to set $base_url

Add a paragraph to description of $base_url variable in gitweb.conf(5) manpage explaining when and why one might need to set it, and how.

---
 Documentation/gitweb.conf.txt |   24 ++++++++++++++++++++++++
 Documentation/gitweb.txt      |    4 ++++
 2 files changed, 28 insertions(+), 0 deletions(-)
Documentation/gitweb.conf.txt +24 -0
index 7aba497..4716a0f 100644
@@ -559,6 +559,30 @@ $base_url::
 	PATH_INFO.  Usually gitweb sets its value correctly,
 	and there is no need to set this variable, e.g. to $my_uri or "/".
 	See `$per_request_config` if you need to override it anyway.
++
+You would need to set this variable when using path_info-based URLs
+while using gitweb as a directory handler (which means that full path
+to browse repositories looks like `http://git.example.com/gitweb`
+rather than looking like `http://git.example.com/gitweb/gitweb.cgi`).
+You can find yourself in this situation (gitweb as directory handler)
+when configuring gitweb to use FastCGI interface as shown in
+"Webserver configuration" section on linkgit:gitweb[1] manpage.
++
+If static files are served from 'static' subdirectory of directory
+the gitweb script is handler for, with default URLs of static files
+(e.g. `$logo` is `static/git-logo.png`), then you would need to ensure
+that `$base_url` ends with slash to denote that it is directory, to
+work correctly:
++
+----------------------------------------------------------------------
+$base_url .= '/' unless ($base_url =~ m!/$!);
+----------------------------------------------------------------------
++
+For example if gitweb URL is `http://git.example.com/gitweb`, and
+static files are available in `http://git.example.com/gitweb/static/`
+then `$base_url` must end up to be `http://git.example.com/gitweb/`
+(with trailing slash) for e.g. `static/git-logo.png` relative link
+to refer to `http://git.example.com/gitweb/static/git-logo.png`.
 
 
 CONFIGURING GITWEB FEATURES
Documentation/gitweb.txt +4 -0
index b394ecc..c3db66a 100644
@@ -473,6 +473,10 @@ With that configuration the full path to browse repositories would be:
 
   http://server/gitweb
 
+Note that for this configuration `$base_url` must be set as described
+in linkgit:gitweb.conf[5] for gitweb to correctly serve static files
+with path_info links.
+
 As PSGI using plackup
 ~~~~~~~~~~~~~~~~~~~~~
 Gitweb can run as PSGI app (via emulation with *CGI::Emulate::PSGI*(3pm)).
Signature · 1 line
1.7.9
#5 lore raw

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hello again,

Quoted 18 lines · Jakub Narebski
Quoted 17 lines · José María Escartín Esteban
Quoted 15 lines · Jakub Narebski
Quoted 11 lines · Jakub Narebski

On Thu, 5 Apr 2012, José María Escartín Esteban wrote:

There might be problem if you configured your web server to serve gitweb using it as a handler for subdirectory, so the script name does not need to appear in URL, e.g.

http://localhost/cgi-bin/gitweb

which would require the following base element

<base href="http://localhost/cgi-bin/gitweb/" />

[...]

Quoted 9 lines
Quoted 1 line

Yes, that was precisely the problem.

Note that you won't have problem with http://localhost as base url (without any directory), or in more realistic case using virtual host rather than virtual directory. The problem is that without '/' the path part of $base_url is stripped of last element.

Just for completeness.

Right.

Quoted 9 lines

[...]

Quoted 5 lines

This addition to the man page would of course have been useful, since it took me a while to detect that the problem was a missing slash in the base url. However, it would not have solved completely my problem, and for me the best has been to add the line of code you proposed in the previous email.

So how about the proposed updated addition at the end of this email?

I think now it's more clear and explicit, and more useful for users not familiar with Perl, so better. Thank you!

Quoted 42 lines
Quoted 13 lines

I am running a Debian testing (wheezy) server, so the distro gitweb files are:

/etc/apache2/conf.d/gitweb /etc/gitweb.conf /usr/share/gitweb/gitweb.cgi /usr/share/gitweb/index.cgi -> /usr/share/gitweb/gitweb.cgi /usr/share/gitweb/static/*

I am using two sets of git repositories, and each of the sets works through a particular gitolite user:

user home ---------------------- git /srv/project mygit
/srv/mygit

Quoted 6 lines

I wanted that different groups of people were able to browse the 'project' repos (in fact it is a mirror from the main project server) from http://server.example.com/project/ , and the 'mygit' repos from
http://server.example.com/mygit/ . And I wanted to keep urls as short and easy as possible, and to avoid proliferation of configs as much as possible.

I think that is this "two sets" that created configuration with a problem.

Quoted 10 lines

The setup I came up with was to link

/srv/www/project -> /usr/share/gitweb /srv/www/mygit -> /usr/share/gitweb

and to use the following configuration files:

######### /etc/apache2/conf.d/gitweb ################## <Directory
/srv/www/project> SetEnv GITWEB_PROJECTROOT /srv/git/ SetEnv
GITWEB_CONFIG /etc/gitweb.conf

[...]

Quoted 8 lines

#######################################################

######### /etc/gitweb.conf ############################ $projectroot = $ENV{'GITWEB_PROJECTROOT'}."repositories"; $git_temp = "/tmp"; $projects_list = $ENV{'GITWEB_PROJECTROOT'}."projects.list"; @diff_opts = (); $feature{'pathinfo'}{'default'} = [1]; $feature{'highlight'}{'default'} = [1]; $projects_list_description_width = 50; #######################################################

Quoted 9 lines

A question: why not have

SetEnv GITWEB_PROJECTROOT /srv/git

and use

$projectroot = "$ENV{'GITWEB_PROJECTROOT'}/repositories"; $projects_list = "$ENV{'GITWEB_PROJECTROOT'}/projects.list";

Aren't both configurations equivalent? (just moving a slash to one side or the other of the definitions)

Quoted 4 lines

BTW. what is this $git_temp? Is it modified gitweb, because core one doesn't need to use temporary directory for anything nowadays?

That option is enabled by default in all the Debian shipped /etc/gitweb.conf.
It was like this the first time I installed the package from the Debian
repos, and it is still like this in the last version of the package in the repos, gitweb_1.7.10-1_all.deb. I didn't know it was any sort of modified gitweb, the script is in git_1.7.10-1_all.deb (yes, they make a separate package for gitweb but the script is in the git one), and the only differences to the v1.7.10 upstream source seem to be installation variables/flags.

Quoted 5 lines

A tip: you can use GITWEB_CONFIG_COMMON for the common part of configuration and separate GITWEB_CONFIG for per-instance configuration. Though I am not sure if it would help in your case. It requires modern gitweb. though.

I will check that, thanks again.

Greetings,

	E.
Quoted 51 lines
Quoted 6 lines

Probably there are better ways to implement this, but at least this seems to work, once I have added

$base_url .= '/' unless ($base_url =~ m!/$!);

to /etc/gitweb.conf .

-- >8 ---------- >8 -- Subject: [PATCH] gitweb.conf(5): When to set $base_url

Add a paragraph to description of $base_url variable in gitweb.conf(5) manpage explaining when and why one might need to set it, and how.

Documentation/gitweb.conf.txt | 24 ++++++++++++++++++++++++
Documentation/gitweb.txt | 4 ++++ 2 files changed, 28
insertions(+), 0 deletions(-)

Documentation/gitweb.conf.txt +0 -0
index 7aba497..4716a0f 100644 --- a/Documentation/gitweb.conf.txt +++

b/Documentation/gitweb.conf.txt @@ -559,6 +559,30 @@ $base_url:: PATH_INFO. Usually gitweb sets its value correctly, and there is no need to set this variable, e.g. to $my_uri or "/". See $per_request_config if you need to override it anyway. ++ +You would need to set this variable when using path_info-based URLs +while using gitweb as a directory handler (which means that full path +to browse repositories looks like http://git.example.com/gitweb +rather than looking like http://git.example.com/gitweb/gitweb.cgi). +You can find yourself in this situation (gitweb as directory handler) +when configuring gitweb to use FastCGI interface as shown in +"Webserver configuration" section on linkgit:gitweb[1] manpage. ++ +If static files are served from 'static' subdirectory of directory +the gitweb script is handler for, with default URLs of static files +(e.g. $logo is static/git-logo.png), then you would need to ensure +that $base_url ends with slash to denote that it is directory, to +work correctly: ++
+----------------------------------------------------------------------
+$base_url .= '/' unless ($base_url =~ m!/$!); +---------------------------------------------------------------------- ++ +For example if gitweb URL is http://git.example.com/gitweb, and +static files are available in http://git.example.com/gitweb/static/ +then $base_url must end up to be http://git.example.com/gitweb/ +(with trailing slash) for e.g. static/git-logo.png relative link +to refer to http://git.example.com/gitweb/static/git-logo.png.

CONFIGURING GITWEB FEATURES diff --git a/Documentation/gitweb.txt b/Documentation/gitweb.txt index b394ecc..c3db66a 100644 --- a/Documentation/gitweb.txt +++ b/Documentation/gitweb.txt @@ -473,6 +473,10 @@ With that configuration the full path to browse repositories would be:

Quoted 6 lines

http://server/gitweb

+Note that for this configuration $base_url must be set as described +in linkgit:gitweb.conf[5] for gitweb to correctly serve static files +with path_info links. + As PSGI using plackup ~~~~~~~~~~~~~~~~~~~~~ Gitweb can run as PSGI app (via emulation with *CGI::Emulate::PSGI*(3pm)).

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iEYEARECAAYFAk+WT9YACgkQY+7weQMem3xchQCcCxsIOs7GOcluIb++KKweK76Y TRcAnjauwtudLCc2qTwJd5D8FxwI34mC
=MbaI
-----END PGP SIGNATURE-----