# [RFD] gitweb configuration

12 messages from 2006-06-17 to 2006-06-18. Participants: Jakub Narebski, Petr Baudis, Martin Langhoff, Timo Hirvonen, Junio C Hamano.
Thread: https://gitlist.dev/t/4546

## Jakub Narebski, 2006-06-17 22:48

Subject: [RFD] gitweb configuration
Message-ID: <e720r0$qdv$1@sea.gmane.org>
URL: https://gitlist.dev/e/e720r0%24qdv%241%40sea.gmane.org

```
Petr Baudis <pasky@suse.cz> writes:
>  - we might want to have a configuration mechanism in place
>    before enhancing gitweb.  My gut feeling is that we can use
>    [gitweb] section in project.git/config (and probably
>    duplicate first and deprecate later existing "description" as
>    well).

The problem is we have different types of configuration in gitweb, and we
should take care where to put appropriate configuration options/variables.

- build time options, like $gitexecdir ($gitbin now) or $gitweb_version 
  ($version now) which could be set at build time a la ./configure i.e
  my $gitexecdir = "@GIT_EXEC_DIR@"; or something like that.

- gitweb installation options (gitweb version need not to correspond to 
  git version, and we could theoretically have more than one gitweb
  installation while one git-core installation). It was proposed to put
  such options on gitweb.conf file in the same directory as gitweb.cgi.
  Unfortunately if one would want to use git-repo-config for managing
  gitweb.conf one is out of luck: git-repo-config uses $GIT_DIR/config.

  Among installation options we could put also defaults for repository-wide
  (repository specific) options.

  Global gitweb options include:
  * $projectroot - absolute fs-path which will be prepended to the 
    project path, i.e. where projects to display are located (dir)
  * $projects_list - source of projects list (file)
  * $home_text - html text to include at home page (file)
  * $stylesheet - default gitweb stylesheet (file)
  * $git_temp - where to place temporary files (dir)

- repository specific options, of which gitweb for now uses only 
  $GIT_DIR/description, and which could use repository configuration,
  [gitweb] section.

  Repository specific options [can] include:
  * description - One line description of repository; 
    theoretical problem: HTML escaping.
  * blame - to make 'blame'/'annotate' interface available.
  * blobmimemapfile - for repository specific mime map for blob_plain.
  * favicon - if default favicon is not used.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Petr Baudis, 2006-06-17 23:23

Subject: Re: [RFD] gitweb configuration
Message-ID: <20060617232358.GK2609@pasky.or.cz>
URL: https://gitlist.dev/e/20060617232358.GK2609%40pasky.or.cz
In-Reply-To: <e720r0$qdv$1@sea.gmane.org>

```
Dear diary, on Sun, Jun 18, 2006 at 12:48:12AM CEST, I got a letter
where Jakub Narebski <jnareb@gmail.com> said that...
> Petr Baudis <pasky@suse.cz> writes:
> >  - we might want to have a configuration mechanism in place
> >    before enhancing gitweb.  My gut feeling is that we can use
> >    [gitweb] section in project.git/config (and probably
> >    duplicate first and deprecate later existing "description" as
> >    well).

(Note that this is what Junio said, not me.)

> - gitweb installation options (gitweb version need not to correspond to 
>   git version, and we could theoretically have more than one gitweb
>   installation while one git-core installation). It was proposed to put
>   such options on gitweb.conf file in the same directory as gitweb.cgi.
>   Unfortunately if one would want to use git-repo-config for managing
>   gitweb.conf one is out of luck: git-repo-config uses $GIT_DIR/config.

In the longer term, perhaps this kind of configuration might land in the
global git configuration file.

---
[PATCH] Support for extracting configuration from different files

Add $GIT_CONFIG environment variable whose content is used instead
of .git/config if set. Also add $GIT_CONFIG_LOCAL as a
forward-compatibility cue for whenever we will finally come to support]
global configuration files (properly).

Signed-off-by: Petr Baudis <pasky@suse.cz>
---

 Documentation/git-repo-config.txt |   12 ++++++++++++
 config.c                          |   12 +++++++++++-
 2 files changed, 23 insertions(+), 1 deletions(-)

diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index d5142e0..803c0d5 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -73,6 +73,18 @@ OPTIONS
 	List all variables set in .git/config.
 
 
+ENVIRONMENT
+-----------
+
+GIT_CONFIG::
+	Take the configuration from the given file instead of .git/config.
+
+GIT_CONFIG_LOCAL::
+	Currently the same as $GIT_CONFIG; when Git will support global
+	configuration files, this will cause it to take the configuration
+	from the global configuration file in addition to the given file.
+
+
 EXAMPLE
 -------
 
diff --git a/config.c b/config.c
index c474970..42e1493 100644
--- a/config.c
+++ b/config.c
@@ -317,7 +317,17 @@ int git_config_from_file(config_fn_t fn,
 
 int git_config(config_fn_t fn)
 {
-	return git_config_from_file(fn, git_path("config"));
+	const char *filename = git_path("config");
+	/* Forward-compatibility cue: $GIT_CONFIG makes git read _only_
+	 * the given config file, $GIT_CONFIG_LOCAL will make it process
+	 * it in addition to the global config file, the same way it would
+	 * the per-repository config file otherwise. */
+	if (getenv("GIT_CONFIG")) {
+		filename = getenv("GIT_CONFIG");
+	} else if (getenv("GIT_CONFIG_LOCAL")) {
+		filename = getenv("GIT_CONFIG_LOCAL");
+	}
+	return git_config_from_file(fn, filename);
 }
 
 /*

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.

```

## Jakub Narebski, 2006-06-18 04:00

Subject: Re: [RFD] gitweb configuration
Message-ID: <e72j53$1m1$1@sea.gmane.org>
URL: https://gitlist.dev/e/e72j53%241m1%241%40sea.gmane.org
In-Reply-To: <20060617232358.GK2609@pasky.or.cz>

```
Petr Baudis wrote:

>> - gitweb installation options (gitweb version need not to correspond to 
>>   git version, and we could theoretically have more than one gitweb
>>   installation while one git-core installation). It was proposed to put
>>   such options on gitweb.conf file in the same directory as gitweb.cgi.
>>   Unfortunately if one would want to use git-repo-config for managing
>>   gitweb.conf one is out of luck: git-repo-config uses $GIT_DIR/config.
> 
> In the longer term, perhaps this kind of configuration might land in the
> global git configuration file.

We could use user's "global" configuration file, ~/.gitconfig, in patch
from Johannes Schindelin (and now in 'pu').

So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be 
$GIT_DIR/config or what?

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Martin Langhoff, 2006-06-18 07:42

Subject: Re: [RFD] gitweb configuration
Message-ID: <46a038f90606180042w7b4d11dbvbea28b750ddbc6e2@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90606180042w7b4d11dbvbea28b750ddbc6e2%40mail.gmail.com
In-Reply-To: <e72j53$1m1$1@sea.gmane.org>

```
On 6/18/06, Jakub Narebski <jnareb@gmail.com> wrote:
> So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be
> $GIT_DIR/config or what?

I don't quite follow why gitweb needs a GIT_CONFIG_LOCAL defined.
Given that it works in a CGI environment, it should read
$GIT_DIR/config by default, and $GIT_CONFIG if set (from httpd.conf).

cheers,


martin

```

## Jakub Narebski, 2006-06-18 08:02

Subject: Re: [RFD] gitweb configuration
Message-ID: <e731ai$su1$1@sea.gmane.org>
URL: https://gitlist.dev/e/e731ai%24su1%241%40sea.gmane.org
In-Reply-To: <46a038f90606180042w7b4d11dbvbea28b750ddbc6e2@mail.gmail.com>

```
Martin Langhoff wrote:

> On 6/18/06, Jakub Narebski <jnareb@gmail.com> wrote:
>> So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be
>> $GIT_DIR/config or what?
> 
> I don't quite follow why gitweb needs a GIT_CONFIG_LOCAL defined.
> Given that it works in a CGI environment, it should read
> $GIT_DIR/config by default, and $GIT_CONFIG if set (from httpd.conf).

When talking about gitweb [installation] configuration, including where to
find GIT projects to display, one needs to remember that gitweb might (and
probably is) installed from binary package and not git.git, and
git/.git/config might not exist.

So we have the following options to separate gitweb-wide options:

- use ~/.gitconfig, /etc/gitconfig or some other global git configuration 
  file, reading values using '$gitexecdir/git-repo-config'.
  Problem: bootstraping, namely value of $gitexecdir ($gitbin now)
  needs to be set in gitweb.cgi, perhaps during the build process.

- use gitweb.conf for configuration, reading values via equivalent of
  'GIT_CONFIG=gitweb.conf $gitexecdir/git-repo-config'. 
  Problem: bootstraping, namely value of $gitexecdir ($gitbin now)
  needs to be set in gitweb.cgi, perhaps during the build process.

- use gitweb.conf for configuration, following the .git/config format,
  writing parsing of ini file (reading only) in Perl from scratch 
  (or use one of many CPAN modules).

- use Perl for configuration file, a la Jon Loeliger <jdl@jdl.com> patch:
   http://marc.theaimsgroup.com/?l=git&m=114308224922372&w=2

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Timo Hirvonen, 2006-06-18 08:30

Subject: Re: [RFD] gitweb configuration
Message-ID: <20060618113052.660e1017.tihirvon@gmail.com>
URL: https://gitlist.dev/e/20060618113052.660e1017.tihirvon%40gmail.com
In-Reply-To: <e731ai$su1$1@sea.gmane.org>

```
Jakub Narebski <jnareb@gmail.com> wrote:

> - use ~/.gitconfig, /etc/gitconfig or some other global git configuration 
>   file, reading values using '$gitexecdir/git-repo-config'.
>   Problem: bootstraping, namely value of $gitexecdir ($gitbin now)
>   needs to be set in gitweb.cgi, perhaps during the build process.

Just use "git command" and you don't have to know $gitexecdir.

-- 
http://onion.dynserv.net/~timo/

```

## Junio C Hamano, 2006-06-18 08:38

Subject: Re: [RFD] gitweb configuration
Message-ID: <7v64iy505x.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v64iy505x.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <46a038f90606180042w7b4d11dbvbea28b750ddbc6e2@mail.gmail.com>

```
"Martin Langhoff" <martin.langhoff@gmail.com> writes:

> On 6/18/06, Jakub Narebski <jnareb@gmail.com> wrote:
>> So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be
>> $GIT_DIR/config or what?
>
> I don't quite follow why gitweb needs a GIT_CONFIG_LOCAL defined.
> Given that it works in a CGI environment, it should read
> $GIT_DIR/config by default, and $GIT_CONFIG if set (from httpd.conf).

I am not Pasky, but I think the intent of the patch is to run
"git repo-config" with GIT_CONFIG pointing at /etc/gitweb.conf
to obtain server-wide configuration (e.g. finding out where
repositories are) and then when serving individual repository
(i.e. after we set up GIT_DIR to point at it) run "git
repo-config" without GIT_CONFIG to read per-repository
configuration.  That way we can reuse the configuration parser.

```

## Jakub Narebski, 2006-06-18 09:12

Subject: Re: [RFD] gitweb configuration
Message-ID: <e735d7$6dq$1@sea.gmane.org>
URL: https://gitlist.dev/e/e735d7%246dq%241%40sea.gmane.org
In-Reply-To: <20060618113052.660e1017.tihirvon@gmail.com>

```
Timo Hirvonen wrote:

> Jakub Narebski <jnareb@gmail.com> wrote:
> 
>> - use ~/.gitconfig, /etc/gitconfig or some other global git configuration 
>>   file, reading values using '$gitexecdir/git-repo-config'.
>>   Problem: bootstraping, namely value of $gitexecdir ($gitbin now)
>>   needs to be set in gitweb.cgi, perhaps during the build process.
> 
> Just use "git command" and you don't have to know $gitexecdir.

First, 'git' might be not in PATH for the webserver user which runs
gitweb.cgi.

Second, I guess that '$gitexecdir/git-repo-config' is/can be faster than
'git repo-config', but if 'git' is in the PATH we can set $gitexecdir from
'git --exec-path'.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Junio C Hamano, 2006-06-18 09:40

Subject: Re: [RFD] gitweb configuration
Message-ID: <7v8xnu3iol.fsf@assigned-by-dhcp.cox.net>
URL: https://gitlist.dev/e/7v8xnu3iol.fsf%40assigned-by-dhcp.cox.net
In-Reply-To: <e735d7$6dq$1@sea.gmane.org>

```
Jakub Narebski <jnareb@gmail.com> writes:

> Timo Hirvonen wrote:
>
>> Just use "git command" and you don't have to know $gitexecdir.
>
> First, 'git' might be not in PATH for the webserver user which runs
> gitweb.cgi.

For that we would have a chicken-and-egg problem if we make
configuration mechanism based on git-repo-config, so I would say
per-site customization is needed somehow.

Hardcoding the path into gitweb.cgi could be one way.
Hardcoding the path to gitweb per-site configuration file and
implement the logic to parse the configuration file without
using git-repo-config would be another.  Even if you wanted to
use "git --exec-path" to bootstrap, not having "git" in the path
would make it, eh, cumbersome.

My gut feeling is that it is sensible to assume git is on
everybody's path -- after all the site is running gitweb and
majority would be using binary packaged distribution, so git
would be installed somewhere sensible and accessible.

So I am with Timo on this one, except that in some cases munging
gitweb.cgi script itself might be needed if the installation
chose to hide git somewhere inaccessible from ordinary users.

```

## Jakub Narebski, 2006-06-18 10:05

Subject: Re: [RFD] gitweb configuration
Message-ID: <e738h3$e74$1@sea.gmane.org>
URL: https://gitlist.dev/e/e738h3%24e74%241%40sea.gmane.org
In-Reply-To: <7v8xnu3iol.fsf@assigned-by-dhcp.cox.net>

```
Junio C Hamano wrote:

> So I am with Timo on this one, except that in some cases munging
> gitweb.cgi script itself might be needed if the installation
> chose to hide git somewhere inaccessible from ordinary users.
                                                ^^^^^^^^^^^^^^

The problem is with webserver user (nobody, web, apache, ...),
which might have nonstandard PATH and/or be run from jail/chroot.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

```

## Martin Langhoff, 2006-06-18 10:13

Subject: Re: [RFD] gitweb configuration
Message-ID: <46a038f90606180313x17ddc6dcpfd9484665468f042@mail.gmail.com>
URL: https://gitlist.dev/e/46a038f90606180313x17ddc6dcpfd9484665468f042%40mail.gmail.com
In-Reply-To: <7v8xnu3iol.fsf@assigned-by-dhcp.cox.net>

```
On 6/18/06, Junio C Hamano <junkio@cox.net> wrote:
> My gut feeling is that it is sensible to assume git is on
> everybody's path -- after all the site is running gitweb and
> majority would be using binary packaged distribution, so git
> would be installed somewhere sensible and accessible.

+1. In the case of binary packages, the maintainer/packager can drop a
config file in /etc/apache/conf.d , so it's unlikely that munging
actually needs to happen.

cheers,


martin

```

## Petr Baudis, 2006-06-18 13:04

Subject: Re: [RFD] gitweb configuration
Message-ID: <20060618130401.GM2609@pasky.or.cz>
URL: https://gitlist.dev/e/20060618130401.GM2609%40pasky.or.cz
In-Reply-To: <7v64iy505x.fsf@assigned-by-dhcp.cox.net>

```
Dear diary, on Sun, Jun 18, 2006 at 10:38:02AM CEST, I got a letter
where Junio C Hamano <junkio@cox.net> said that...
> "Martin Langhoff" <martin.langhoff@gmail.com> writes:
> 
> > On 6/18/06, Jakub Narebski <jnareb@gmail.com> wrote:
> >> So GIT_CONFIG would be ~/.gitconfig, and GIT_CONFIG_LOCAL would be
> >> $GIT_DIR/config or what?
> >
> > I don't quite follow why gitweb needs a GIT_CONFIG_LOCAL defined.
> > Given that it works in a CGI environment, it should read
> > $GIT_DIR/config by default, and $GIT_CONFIG if set (from httpd.conf).
> 
> I am not Pasky, but I think the intent of the patch is to run
> "git repo-config" with GIT_CONFIG pointing at /etc/gitweb.conf
> to obtain server-wide configuration (e.g. finding out where
> repositories are) and then when serving individual repository
> (i.e. after we set up GIT_DIR to point at it) run "git
> repo-config" without GIT_CONFIG to read per-repository
> configuration.  That way we can reuse the configuration parser.

Yes, if $GIT_CONFIG is set, git should be guaranteed to read _no_ config
file except $GIT_CONFIG. The intent of $GIT_LOCAL_CONFIG was to make it
possible to just override the per-repo configfile location, but it just
felt nice to have - I don't insist on it so if people think it's useless
additional complexity I'm happy to say that one goodbye.

-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.

```
