Am 2023-02-10 00:05, schrieb Junio C Hamano:
Daniel Abrecht <git-git@xxxxxxxxxxxxxxxxxxxxxxxx> writes:
+ # the browser will strip away the last component for relative URLs.
+ # Add the / if it's missing.
The above is not an incorrect statement per-se, but if $base were
pointing at the document, we would likely break if we add an extra
slash. Don't we want to say something like
# $base_url at this point points at a directory, not a
# single document, and later is used in the <base> tag.
# Make sure it ends in a '/'. Otherwise, we'd lose the last
# component when forming a relative URL.
perhaps?
After thinking about this for a while, I realized that this isn't as
simple as I thought.
I'm currently using apache and some rewrite rules so I can access
projects at /git/myproject.git/ (See my config below).
So in my case, $base_url is /git at this point, and I need to add a /.
But if I didn't have those rewrite rules, I could instead access the
repos using /git/gitweb.cgi/myproject.git/ .
In that case, $base_url would be /git/gitweb.cgi at this point, so it
does refer to the script / document.
The assets are still at /git/ and not at /git/gitweb.cgi/, so links are
relative to /git/gitweb.cgi/ but assets are
relative to /git/. It seams relative URLs are only used for assets, so
the $base_url should really be /git/gitweb.cgi
or alternatively just /git/ there, and just adding a slash would be
wrong in that case.
Given this, I no longer think I should change the way it currently is.
I will just override $base_url in my config file instead.
<Macro gitweb $location>
SetEnv GITWEB_CONFIG /etc/gitweb.conf
SetEnv GIT_HTTP_EXPORT_ALL
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/lib/git-core/git-http-backend/$1
Alias $location/ /usr/share/gitweb/
RewriteRule
^$location/.*\.git/(HEAD|info|objects|refs|git-(upload|receive)-pack) -
[E=GIT_PROJECT_ROOT:%{DOCUMENT_ROOT}$location/,PT,END]
RewriteRule ^$location/(.*\.git(/.*)?)?$ $location/gitweb.cgi/$1
[E=GIT_PROJECT_ROOT:%{DOCUMENT_ROOT}$location/,L,PT]
<Location $location>
Require all granted
AllowOverride None
</Location>
<Directory /usr/share/gitweb/>
Options +FollowSymLinks +ExecCGI
AddHandler cgi-script .cgi
</Directory>
</Macro>
<VirtualHost *:443>
Use VHostSSL projects.dpa.li
DocumentRoot /var/www/projects.dpa.li/
Use gitweb /git
</VirtualHost>