threads / discuss / 25858

Re: gitweb: false base href sent when integrated via reverse proxy and path_info is active

Subject: Re: gitweb: false base href sent when integrated via reverse proxy and path_info is active

## tl;dr

15 messages between Nov 28, 2010 and Dec 1, 2010.

replies: 14people: 5as markdown or json

Jonathan Nieder· Nov 28, 2010, 16:27 UTC · lore
Hi Jakub et al,
Daniel Reichelt wrote[1]:
Show 11 quoted lines
> I just noticed that integrating gitweb via reverse proxy is impossible when
> path_info is enabled in gitweb.conf. The base href sent on gitweb.cgi:3427
> contains the "internal" URL called by the reverse proxy mechanism, not the
> original one called by the user agent which makes it impossible for the
> client to display CSS, images, etc...
> 
> I suggest an additional config variable, e.g.
> $feature{'pathinfo'}{'basehrefoverride'} which could override the base href
> tag determinted by the cgi script (or disable sending a base href tag at all
> - at least I was able to achieve my desired setup by adjusting the URLs for
> CSS etc in gitweb.conf to fitting absolute URLs).
Any advice for Daniel?  Is it a good idea?

Regards, Jonathan

[1] http://bugs.debian.org/605217
Giuseppe Bilotta· Nov 28, 2010, 17:25 UTC · re: Jonathan Nieder · lore
On Sun, Nov 28, 2010 at 5:27 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 17 quoted lines
> Hi Jakub et al,
>
> Daniel Reichelt wrote[1]:
>
>> I just noticed that integrating gitweb via reverse proxy is impossible when
>> path_info is enabled in gitweb.conf. The base href sent on gitweb.cgi:3427
>> contains the "internal" URL called by the reverse proxy mechanism, not the
>> original one called by the user agent which makes it impossible for the
>> client to display CSS, images, etc...
>>
>> I suggest an additional config variable, e.g.
>> $feature{'pathinfo'}{'basehrefoverride'} which could override the base href
>> tag determinted by the cgi script (or disable sending a base href tag at all
>> - at least I was able to achieve my desired setup by adjusting the URLs for
>> CSS etc in gitweb.conf to fitting absolute URLs).
>
> Any advice for Daniel?  Is it a good idea?

I'm not familiar with the way reverse proxies operate. Is there some information that the script can scrape to understand that its request is being reverse-proxied? Or are there options that the reverse proxies can be configured with to pretend that the URL is not being rewritten? These would be better solutions.

Lacking that, a plain
our $base_url  = 'whatever';

in the gitweb config should probably work, as the gitweb config is evaluated _after_ the internal URI variables are set. Can the bug submitter confirm that this does indeed work?

-- 
Giuseppe "Oblomov" Bilotta
Jakub Narebski· Nov 28, 2010, 17:47 UTC · re: Giuseppe Bilotta · lore
On Sun, 28 Nov 2010, Giuseppe Bilotta wrote:
Show 32 quoted lines
> On Sun, Nov 28, 2010 at 5:27 PM, Jonathan Nieder <jrnieder@gmail.com> wrote:
>> Hi Jakub et al,
>>
>> Daniel Reichelt wrote[1]:
>>
>>> I just noticed that integrating gitweb via reverse proxy is impossible when
>>> path_info is enabled in gitweb.conf. The base href sent on gitweb.cgi:3427
>>> contains the "internal" URL called by the reverse proxy mechanism, not the
>>> original one called by the user agent which makes it impossible for the
>>> client to display CSS, images, etc...
>>>
>>> I suggest an additional config variable, e.g.
>>> $feature{'pathinfo'}{'basehrefoverride'} which could override the base href
>>> tag determinted by the cgi script (or disable sending a base href tag at all
>>> - at least I was able to achieve my desired setup by adjusting the URLs for
>>> CSS etc in gitweb.conf to fitting absolute URLs).
>>
>> Any advice for Daniel?  Is it a good idea?
> 
> I'm not familiar with the way reverse proxies operate. Is there some
> information that the script can scrape to understand that its request
> is being reverse-proxied? Or are there options that the reverse
> proxies can be configured with to pretend that the URL is not being
> rewritten? These would be better solutions.
> 
> Lacking that, a plain
> 
> our $base_url  = 'whatever';
> 
> in the gitweb config should probably work, as the gitweb config is
> evaluated _after_ the internal URI variables are set. Can the bug
> submitter confirm that this does indeed work?
See also gitweb/README, the "Gitweb config file variables" section:
 * $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 only for URLs with nonempty PATH_INFO via
   <base href="$base_url">.  Usually gitweb sets its value correctly,
                             ^^^^^^^
   and there is no need to set this variable, e.g. to $my_uri or "/".
The key word here is "usually" ;-)
-- 
Jakub Narebski
Poland
Jonathan Nieder· Nov 28, 2010, 18:12 UTC · re: Jakub Narebski · lore
Jakub Narebski wrote:
Show 11 quoted lines
> See also gitweb/README, the "Gitweb config file variables" section:
> 
>  * $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 only for URLs with nonempty PATH_INFO via
>    <base href="$base_url">.  Usually gitweb sets its value correctly,
>                              ^^^^^^^
>    and there is no need to set this variable, e.g. to $my_uri or "/".
> 
> The key word here is "usually" ;-)
Thanks, all.  That helps.

No time for it at the moment, but I'm taking this as evidence that we need a gitweb.conf(5) manual page. :) Would you be interested in such a thing (as POD or asciidoc)?

Jonathan
Jakub Narebski· Nov 30, 2010, 18:22 UTC · re: Jonathan Nieder · lore
On Sun, 28 Nov 2010, Jonathan Nieder wrote:
Show 19 quoted lines
> Jakub Narebski wrote:
> 
> > See also gitweb/README, the "Gitweb config file variables" section:
> > 
> >  * $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 only for URLs with nonempty PATH_INFO via
> >    <base href="$base_url">.  Usually gitweb sets its value correctly,
> >                              ^^^^^^^
> >    and there is no need to set this variable, e.g. to $my_uri or "/".
> > 
> > The key word here is "usually" ;-)
> 
> Thanks, all.  That helps.
> 
> No time for it at the moment, but I'm taking this as evidence that
> we need a gitweb.conf(5) manual page. :)  Would you be interested
> in such a thing (as POD or asciidoc)?

Well, both git-gui and gitk have their documentation in Documentation/ (in AsciiDoc format), so perhaps it is time to add Documentation/gitweb.txt and possibly also Documentation/gitweb_config.txt (or gitweb.conf.txt).

With exception of t/README, the gitweb/README file is largest, with around 570 lines, while next largest is (discarding also git-gui/po/README) main README file with around 50 lines.

-- 
Jakub Narebski
Poland
Junio C Hamano· Dec 1, 2010, 03:25 UTC · re: Jakub Narebski · lore
Jakub Narebski <jnareb@gmail.com> writes:
> Well, both git-gui and gitk have their documentation in Documentation/
> (in AsciiDoc format), so perhaps it is time to add Documentation/gitweb.txt
> and possibly also Documentation/gitweb_config.txt (or gitweb.conf.txt).
That indeed sounds like a good idea to me.
Daniel Reichelt· Nov 28, 2010, 20:30 UTC · re: Jakub Narebski · lore
Hi all
>> I'm not familiar with the way reverse proxies operate. Is there some
>> information that the script can scrape to understand that its request
>> is being reverse-proxied?
Nope. Reverse proxy works like this:
- a "public" apache VirtualHost receives an http(s) request for a
certain URL /a/b/c... and has the location /a/.* configured as a
revProxy location
- the public vhost repeats that request to the revProxy target
- the revProxy target receives a request from the "public" vhost and
serves it as usual (this is were the gitweb.cgi script actually is run,
only seeing the request made by the public vhost, not the initially
requesting client, thus all information about the publicly visible git
URI is lost and never gets passed on to gitweb.cgi)
- the public vhost receives the response and forwards it to the client,
pretending he himself had answered the request
Show 5 quoted lines
>> Lacking that, a plain
>>
>> our $base_url  = 'whatever';
>>
>> in the gitweb config should probably work
Nope again, I'm afraid it doesn't (see further down)
Show 12 quoted lines
> See also gitweb/README, the "Gitweb config file variables" section:
> 
>  * $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 only for URLs with nonempty PATH_INFO via
>    <base href="$base_url">.  Usually gitweb sets its value correctly,
>                              ^^^^^^^
>    and there is no need to set this variable, e.g. to $my_uri or "/".
> 
> The key word here is "usually" ;-)
> 
*oops* thank you all for the hint! I totally missed that.

However, I just tried that and it failed. $base_url gets ignored in gitweb.conf and even setting $my_url and $my_uri in gitweb.conf seems to have no effect at all. For testing purposes I printed the relevant variables to the html header:

gitweb.conf: ************ our $feature{'pathinfo'}{'default'} = [1]; our $base_url = "https://foobar"; our $my_url = "https://foo"; our $my_uri = "https://bar"; ************

gitweb.cgi:3424
************
# the stylesheet, favicon etc urls won't work correctly with path_info
# unless we set the appropriate base URL
if ($ENV{'PATH_INFO'}) {
        print "<base href=\"".esc_url($base_url)."\" />\n";
}
print "<!--
$base_url
$my_url
$my_uri
-->";
************
- git repo listing
public url: https://sb74/projects/gitweb
revProxy url: https://localhost:446/projects/gitweb
************
<head>
<meta http-equiv="content-type" content="application/xhtml+xml;
charset=utf-8"/>
<meta name="generator" content="gitweb/1.7.2.3 git/1.7.2.3"/>
<meta name="robots" content="index, nofollow"/>
<title>localhost Git</title>
<!--
		https://sb74:446/projects/gitweb
		https://sb74:446/projects/gitweb
		/projects/gitweb
		--><link rel="stylesheet" type="text/css"
href="/projects/gitweb/gitweb/gitweb.css"/>
<link rel="alternate" title="localhost Git projects list"
href="/projects/gitweb?a=project_index" type="text/plain; charset=utf-8" />
<link rel="alternate" title="localhost Git projects feeds"
href="/projects/gitweb?a=opml" type="text/x-opml" />
<link rel="shortcut icon" href="/projects/gitweb/gitweb/git-favicon.png"
type="image/png" />
</head>
************
- git summary of repo "test1"
public url: https://sb74/projects/gitweb/test1/summary
revProxy url: https://localhost:446/projects/gitweb/test1/summary
************
<head>
<meta http-equiv="content-type" content="application/xhtml+xml;
charset=utf-8"/>
<meta name="generator" content="gitweb/1.7.2.3 git/1.7.2.3"/>
<meta name="robots" content="index, nofollow"/>
<title>localhost Git - test1/summary</title>
<base href="https://sb74:446/projects/gitweb" />
<!--
		https://sb74:446/projects/gitweb
		https://sb74:446/projects/gitweb
		/projects/gitweb
		--><link rel="stylesheet" type="text/css"
href="/projects/gitweb/gitweb/gitweb.css"/>
<link rel="alternate" title="test1 - log - RSS feed"
href="/projects/gitweb/test1/rss" type="application/rss+xml" />
<link rel="alternate" title="test1 - log - RSS feed (no merges)"
href="/projects/gitweb/test1/rss?opt=--no-merges"
type="application/rss+xml" />
<link rel="alternate" title="test1 - log - Atom feed"
href="/projects/gitweb/test1/atom?opt=--no-merges"
type="application/atom+xml" />
<link rel="alternate" title="test1 - log - Atom feed (no merges)"
href="/projects/gitweb/test1/atom?opt=--no-merges"
type="application/atom+xml" />

<link rel="shortcut icon" href="/projects/gitweb/gitweb/git-favicon.png" type="image/png" /> </head> ************

Any ideas?

Regards Daniel

Jakub Narebski· Nov 28, 2010, 21:07 UTC · re: Daniel Reichelt · lore
On Sun, 28 Nov 2010, Daniel Reichelt wrote:
Show 7 quoted lines
>>> Lacking that, a plain
>>>
>>> our $base_url  = 'whatever';
>>>
>>> in the gitweb config should probably work
> 
> Nope again, I'm afraid it doesn't (see further down)
Strange, it works for me (see below). 
 
Show 23 quoted lines
>> See also gitweb/README, the "Gitweb config file variables" section:
>> 
>>  * $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 only for URLs with nonempty PATH_INFO via
>>    <base href="$base_url">.  Usually gitweb sets its value correctly,
>>                              ^^^^^^^
>>    and there is no need to set this variable, e.g. to $my_uri or "/".
>> 
>> The key word here is "usually" ;-)
>> 
> 
> *oops* thank you all for the hint! I totally missed that.
> 
> However, I just tried that and it failed. $base_url gets ignored in
> gitweb.conf and even setting $my_url and $my_uri in gitweb.conf seems to
> have no effect at all. For testing purposes I printed the relevant
> variables to the html header:
> 
> 
> gitweb.conf:
> ************

The default name of gitweb config file is gitweb_config.perl, not gitweb.conf. Are you sure you are picking correct config file?

> our $feature{'pathinfo'}{'default'} = [1];
> our $base_url = "https://foobar";
> our $my_url = "https://foo";
> our $my_uri = "https://bar";
Try adding
  our $site_name = "foo";
to check if you are picking correct config file.
Show 10 quoted lines
> - git summary of repo "test1"
> public url: https://sb74/projects/gitweb/test1/summary
> revProxy url: https://localhost:446/projects/gitweb/test1/summary
> ************
> <head>
> <meta http-equiv="content-type" content="application/xhtml+xml; charset=utf-8"/>
> <meta name="generator" content="gitweb/1.7.2.3 git/1.7.2.3"/>
> <meta name="robots" content="index, nofollow"/>
> <title>localhost Git - test1/summary</title>
> <base href="https://sb74:446/projects/gitweb" />
[...]
> </head>
I get the following when running with config file that contains:
  our $version = "current";
  [...]
  our $site_name = "[localhost]";
  [...]
  our $base_url = "https://localhost/gitweb/";
$ gitweb-run.sh "" "/git.git"
  [...]
  <head>
  <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
  <meta name="generator" content="gitweb/current git/1.7.3.2.171.g8ccd7"/>
  <meta name="robots" content="index, nofollow"/>
  <title>[localhost] - git.git/summary</title>
  <base href="https://localhost/gitweb/" />
  [...]
So it works for me.
-- 
Jakub Narebski
Poland
Daniel Reichelt· Nov 28, 2010, 21:25 UTC · re: Jakub Narebski · lore
> The default name of gitweb config file is gitweb_config.perl, not
> gitweb.conf.  Are you sure you are picking correct config file?
Suppose this is Debian-specific:
************
our ($GITWEB_CONFIG, $GITWEB_CONFIG_SYSTEM);
sub evaluate_gitweb_config {
        our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "gitweb_config.perl";
        our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} ||
"/etc/gitweb.conf";
        # die if there are errors parsing config file
        if (-e $GITWEB_CONFIG) {
                do $GITWEB_CONFIG;
                die $@ if $@;
        } elsif (-e $GITWEB_CONFIG_SYSTEM) {
                do $GITWEB_CONFIG_SYSTEM;
                die $@ if $@;
        }
}
************
Show 5 quoted lines
> Try adding
>
>   our $site_name = "foo";
>
> to check if you are picking correct config file.
Yap, $site_name shows up in my browser's title.
Jonathan Nieder· Nov 28, 2010, 21:10 UTC · re: Daniel Reichelt · lore
Daniel Reichelt wrote:
> However, I just tried that and it failed. $base_url gets ignored in
> gitweb.conf and even setting $my_url and $my_uri in gitweb.conf seems to
> have no effect at all.

Aha. The bug fixed by v1.7.3-rc0~85^2 (gitweb: allow configurations that change with each request, 2010-07-30) strikes again.

Daniel, could you try again with version 1:1.7.2.3-2.1 (from Debian sid)?

Jakub, we should probably tweak evaluate_uri to do something special if $base_url is already set, or advertise that $base_url needs to be set in per_request_config when that feature is enabled.

Thanks again. Jonathan

Daniel Reichelt· Nov 28, 2010, 21:28 UTC · re: Jonathan Nieder · lore
> Aha.  The bug fixed by v1.7.3-rc0~85^2 (gitweb: allow configurations
> that change with each request, 2010-07-30) strikes again.
>
> Daniel, could you try again with version 1:1.7.2.3-2.1 (from Debian sid)?

Yay - now setting $base_url in gitweb.conf works (and on a side note $my_url and $my_uri as well). Thanks to all of you guys for helping in tracking this down.

Cheers Daniel

Jakub Narebski· Nov 28, 2010, 22:05 UTC · re: Jonathan Nieder · lore
On Sun, 28 Nov 2010, Jonathan Nieder wrote:
Show 14 quoted lines
> Daniel Reichelt wrote:
> 
> > However, I just tried that and it failed. $base_url gets ignored in
> > gitweb.conf and even setting $my_url and $my_uri in gitweb.conf seems to
> > have no effect at all.
> 
> Aha.  The bug fixed by v1.7.3-rc0~85^2 (gitweb: allow configurations
> that change with each request, 2010-07-30) strikes again.
> 
> Daniel, could you try again with version 1:1.7.2.3-2.1 (from Debian sid)?
> 
> Jakub, we should probably tweak evaluate_uri to do something special if
> $base_url is already set, or advertise that $base_url needs to be set
> in per_request_config when that feature is enabled.
Jonathan, something like this, perhaps?
-- >8 ---- >8 --
From: Jakub Narebski <jnareb@gmail.com>
Subject: [PATCH/RFC] gitweb: Preserve $base_url if it was set

If $base_url was defined, then do not redefine it in evaluate_uri(). This matters only in the case when $base_url was set in gitweb config file, and $per_request_config is false or is coderef; without this change $base_url would get overwritten on subsequent requests from the value set in config.

If you need $base_url that can change with request, but the default value set by gitweb doesn't work for you, and you want most of gitweb config file to be evaluated only once, you need to use $per_request_config coderef to set it.

Possible-issue-reported-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
On top of (gitweb: selectable configurations that change with each
request, 2010-11-28).
 gitweb/gitweb.perl |   13 ++++++++-----
 1 files changed, 8 insertions(+), 5 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 1d94718..5efee0d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -36,10 +36,9 @@ sub evaluate_uri {
 	our $my_url = $cgi->url();
 	our $my_uri = $cgi->url(-absolute => 1);
 
-	# Base URL for relative URLs in gitweb ($logo, $favicon, ...),
-	# needed and used only for URLs with nonempty PATH_INFO
-	our $base_url = $my_url;
-
+	# $base_url contains base URL for relative URLs in gitweb ($logo, $favicon, ...);
+	# it is needed and it is used only for URLs with nonempty PATH_INFO
+	#
 	# When the script is used as DirectoryIndex, the URL does not contain the name
 	# of the script file itself, and $cgi->url() fails to strip PATH_INFO, so we
 	# have to do it ourselves. We make $path_info global because it's also used
@@ -57,7 +56,11 @@ sub evaluate_uri {
 		if ($my_url =~ s,\Q$path_info\E$,, &&
 		    $my_uri =~ s,\Q$path_info\E$,, &&
 		    defined $ENV{'SCRIPT_NAME'}) {
-			$base_url = $cgi->url(-base => 1) . $ENV{'SCRIPT_NAME'};
+			# preserve existing $base_url
+			$base_url ||= $cgi->url(-base => 1) . $ENV{'SCRIPT_NAME'};
+		} else {
+			# in case e.g. $ENV{'SCRIPT_NAME'} is not defined
+			$base_url ||= $my_url;
 		}
 	}
 
-- 
1.7.3
Jonathan Nieder· Nov 29, 2010, 00:19 UTC · re: Jakub Narebski · lore

Re: [PATCH/RFC] gitweb: Preserve $base_url if it was set

Jakub Narebski wrote:
> If $base_url was defined, then do not redefine it in evaluate_uri().
How about $my_uri and $my_url?

What happens if $ENV{PATH_INFO} or $cgi->url(...) changes between requests? This is partly my ignorance: perhaps FastCGI et al guarantee that such configuration changes can't happen within a single process?

Maintaining backward compatibility while avoiding this last concern seems hard. Since gitweb_config can contain something like

	$my_uri =~ s/foo/bar/;

one would want to populate $my_uri in advance. Meanwhile, if the default for $my_uri could change between requests, we would want to be able to detect the case when $my_uri is not set. But what if gitweb_config contains

	$my_uri = "something";

where "something" happens to match the default value for $my_uri in the first request?

It is tempting to change the documentation now and worry about code changes later. Something like this?

Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
diff --git a/gitweb/README b/gitweb/README
index 6646fda..a9421e0 100644
--- a/gitweb/README
+++ b/gitweb/README
@@ -177,13 +177,15 @@ not include variables usually directly set during build):
  * $my_url, $my_uri
    Full URL and absolute URL of gitweb script;
    in earlier versions of gitweb you might have need to set those
-   variables, now there should be no need to do it.
+   variables, now there should be no need to do it.  See
+   $per_request_config if you need to set them still.
  * $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 only for URLs with nonempty PATH_INFO via
    <base href="$base_url">.  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 set it anyway.
  * $home_link
    Target of the home link on top of all pages (the first part of view
    "breadcrumbs").  By default set to absolute URI of a page ($my_uri).
@@ -252,7 +254,10 @@ not include variables usually directly set during build):
      sub { $ENV{GL_USER} = $cgi->remote_user || "gitweb"; }
    Otherwise it is treated as boolean value: if true gitweb would process
    config file once per request, if false it would process config file only
-   once.  The default is true.
+   once.  Note: $my_url, $my_uri, and $base_url are overwritten with
+   their default values before every request, so if you want to change
+   them, be sure to set this variable to true or a code reference effecting
+   the desired changes.  The default is true.
 
 Projects list file format
 ~~~~~~~~~~~~~~~~~~~~~~~~~
Jakub Narebski· Nov 29, 2010, 00:51 UTC · re: Jonathan Nieder · lore

Re: [PATCH/RFC] gitweb/README: About $base_url etc. and $per_request_config

Subject fixed.
On Mon, 29 Nov 2010, Jonathan Nieder wrote:
Show 10 quoted lines
> Jakub Narebski wrote:
> 
> > If $base_url was defined, then do not redefine it in evaluate_uri().
> 
> How about $my_uri and $my_url?
> 
> What happens if $ENV{PATH_INFO} or $cgi->url(...) changes between
> requests?  This is partly my ignorance: perhaps FastCGI et al
> guarantee that such configuration changes can't happen within a single
> process?

I think that at least $ENV{PATH_INFO} can change with request, though I guess that $base_url should not change from request to request... though there might be some corner cases.

$my_uri and $my_url usually do change with each request...
Show 20 quoted lines
>
> Maintaining backward compatibility while avoiding this last concern
> seems hard.  Since gitweb_config can contain something like
> 
> 	$my_uri =~ s/foo/bar/;
> 
> one would want to populate $my_uri in advance.  Meanwhile, if the
> default for $my_uri could change between requests, we would want to be
> able to detect the case when $my_uri is not set.  But what if
> gitweb_config contains
> 
> 	$my_uri = "something";
> 
> where "something" happens to match the default value for $my_uri in
> the first request?
> 
> It is tempting to change the documentation now and worry about code
> changes later.  Something like this?
> 
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
..therefore I think it is a better solution.
Acked-by: Jakub Narebski <jnareb@gmail.com>
Show 12 quoted lines
> ---
> diff --git a/gitweb/README b/gitweb/README
> index 6646fda..a9421e0 100644
> --- a/gitweb/README
> +++ b/gitweb/README
> @@ -177,13 +177,15 @@ not include variables usually directly set during build):
>   * $my_url, $my_uri
>     Full URL and absolute URL of gitweb script;
>     in earlier versions of gitweb you might have need to set those
> -   variables, now there should be no need to do it.
> +   variables, now there should be no need to do it.  See
> +   $per_request_config if you need to set them still.
Very minor nitpick: perhaps it would be better to use
      variables, now there should be no need to do it.
  +   See $per_request_config if you need to set them still.
Show 19 quoted lines
>   * $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 only for URLs with nonempty PATH_INFO via
>     <base href="$base_url">.  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 set it anyway.
>   * $home_link
>     Target of the home link on top of all pages (the first part of view
>     "breadcrumbs").  By default set to absolute URI of a page ($my_uri).
> @@ -252,7 +254,10 @@ not include variables usually directly set during build):
>       sub { $ENV{GL_USER} = $cgi->remote_user || "gitweb"; }
>     Otherwise it is treated as boolean value: if true gitweb would process
>     config file once per request, if false it would process config file only
> -   once.  The default is true.
> +   once.  Note: $my_url, $my_uri, and $base_url are overwritten with
> +   their default values before every request, so if you want to change
> +   them, be sure to set this variable to true or a code reference effecting
> +   the desired changes.  The default is true. 
Perhaps:
      once.  The default is true.
  +   Note: $my_url, $my_uri, and $base_url are overwritten with
  +   their default values before every request, so if you want to change
  +   them, be sure to set this variable to true or a code reference effecting
  +   the desired changes.
  
-- 
Jakub Narebski
Poland
Junio C Hamano· Nov 29, 2010, 17:57 UTC · re: Jonathan Nieder · lore

Re: [PATCH/RFC] gitweb: Preserve $base_url if it was set

Jonathan Nieder <jrnieder@gmail.com> writes:
Show 17 quoted lines
> Jakub Narebski wrote:
>
>> If $base_url was defined, then do not redefine it in evaluate_uri().
>
> How about $my_uri and $my_url?
>
> What happens if $ENV{PATH_INFO} or $cgi->url(...) changes between
> requests?  This is partly my ignorance: perhaps FastCGI et al
> guarantee that such configuration changes can't happen within a single
> process?
>
> Maintaining backward compatibility while avoiding this last concern
> seems hard....
> It is tempting to change the documentation now and worry about code
> changes later.  Something like this?
>
> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>

Sounds like a sensible thing to do; narrows an interface with two variables into a more flexible new interface with a single variable.

Show 34 quoted lines
> ---
> diff --git a/gitweb/README b/gitweb/README
> index 6646fda..a9421e0 100644
> --- a/gitweb/README
> +++ b/gitweb/README
> @@ -177,13 +177,15 @@ not include variables usually directly set during build):
>   * $my_url, $my_uri
>     Full URL and absolute URL of gitweb script;
>     in earlier versions of gitweb you might have need to set those
> -   variables, now there should be no need to do it.
> +   variables, now there should be no need to do it.  See
> +   $per_request_config if you need to set them still.
>   * $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 only for URLs with nonempty PATH_INFO via
>     <base href="$base_url">.  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 set it anyway.
>   * $home_link
>     Target of the home link on top of all pages (the first part of view
>     "breadcrumbs").  By default set to absolute URI of a page ($my_uri).
> @@ -252,7 +254,10 @@ not include variables usually directly set during build):
>       sub { $ENV{GL_USER} = $cgi->remote_user || "gitweb"; }
>     Otherwise it is treated as boolean value: if true gitweb would process
>     config file once per request, if false it would process config file only
> -   once.  The default is true.
> +   once.  Note: $my_url, $my_uri, and $base_url are overwritten with
> +   their default values before every request, so if you want to change
> +   them, be sure to set this variable to true or a code reference effecting
> +   the desired changes.  The default is true.
>  
>  Projects list file format
>  ~~~~~~~~~~~~~~~~~~~~~~~~~

← back to recent threads