threads / discuss / 4546

[RFD] gitweb configuration

Subject: [RFD] gitweb configuration

## tl;dr

12 messages between Jun 17, 2006 and Jun 18, 2006.

replies: 11people: 5as markdown or json

Jakub Narebski· Jun 17, 2006, 22:48 UTC · lore
Petr Baudis <pasky@suse.cz> writes:
Show 5 quoted lines
>  - 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· Jun 17, 2006, 23:23 UTC · re: Jakub Narebski · lore

Re: [RFD] gitweb configuration

Dear diary, on Sun, Jun 18, 2006 at 12:48:12AM CEST, I got a letter where Jakub Narebski <jnareb@gmail.com> said that...

Show 6 quoted lines
> 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.)
Show 6 quoted lines
> - 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· Jun 18, 2006, 04:00 UTC · re: Petr Baudis · lore

Re: [RFD] gitweb configuration

Petr Baudis wrote:
Show 9 quoted lines
>> - 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· Jun 18, 2006, 07:42 UTC · re: Jakub Narebski · lore

Re: [RFD] gitweb configuration

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· Jun 18, 2006, 08:02 UTC · re: Martin Langhoff · lore

Re: [RFD] gitweb configuration

Martin Langhoff wrote:
Show 7 quoted lines
> 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· Jun 18, 2006, 08:30 UTC · re: Jakub Narebski · lore

Re: [RFD] gitweb configuration

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/
Jakub Narebski· Jun 18, 2006, 09:12 UTC · re: Timo Hirvonen · lore

Re: [RFD] gitweb configuration

Timo Hirvonen wrote:
Show 8 quoted lines
> 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· Jun 18, 2006, 09:40 UTC · re: Jakub Narebski · lore

Re: [RFD] gitweb configuration

Jakub Narebski <jnareb@gmail.com> writes:
Show 6 quoted lines
> 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· Jun 18, 2006, 10:05 UTC · re: Junio C Hamano · lore

Re: [RFD] gitweb configuration

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· Jun 18, 2006, 10:13 UTC · re: Junio C Hamano · lore

Re: [RFD] gitweb configuration

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
Junio C Hamano· Jun 18, 2006, 08:38 UTC · re: Martin Langhoff · lore

Re: [RFD] gitweb configuration

"Martin Langhoff" <martin.langhoff@gmail.com> writes:
Show 7 quoted lines
> 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.

Petr Baudis· Jun 18, 2006, 13:04 UTC · re: Junio C Hamano · lore

Re: [RFD] gitweb configuration

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...

Show 17 quoted lines
> "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.

← back to recent threads