Skip to contentSkip to conversation

gitweb configuration

RFD Jakub Narebski 5 participants 12 messages Jun 15, 2016 Documentation

lore
Share & tools
lore
#0 lore raw
Quoted 5 lines · Petr Baudis

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

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#1 lore raw

Dear diary, on Sun, Jun 18, 2006 at 12:48:12AM CEST, I got a letter where Jakub Narebski <[email protected]> said that...

Quoted 6 lines
Quoted 5 lines · Petr Baudis

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

Quoted 6 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).

---

 Documentation/git-repo-config.txt |   12 ++++++++++++
 config.c                          |   12 +++++++++++-
 2 files changed, 23 insertions(+), 1 deletions(-)
Documentation/git-repo-config.txt +12 -0
index d5142e0..803c0d5 100644
@@ -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
 -------
 
config.c +11 -1
index c474970..42e1493 100644
@@ -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);
 }
 
 /*
Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
#2 lore raw
Quoted 9 lines · Petr Baudis
Quoted 6 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?

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#3 lore raw
Quoted 2 lines · Jakub Narebski

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

#4 lore raw
Quoted 7 lines · Martin Langhoff
Quoted 2 lines · Jakub Narebski

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.

#5 lore raw

Dear diary, on Sun, Jun 18, 2006 at 10:38:02AM CEST, I got a letter where Junio C Hamano <[email protected]> said that...

Quoted 10 lines
Quoted 7 lines · Martin Langhoff
Quoted 2 lines · Jakub Narebski

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

Quoted 7 lines

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.

Signature · 3 lines
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
A person is just about as big as the things that make them angry.
#6 lore raw
In reply to Martin Langhoff
Quoted 7 lines · Martin Langhoff
Quoted 2 lines · Jakub Narebski

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 <[email protected]> patch:
http://marc.theaimsgroup.com/?l=git&m=114308224922372&w=2

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#7 lore raw
Quoted 4 lines · Jakub Narebski

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

Signature · 1 line
http://onion.dynserv.net/~timo/
#8 lore raw
Quoted 8 lines · Timo Hirvonen
Quoted 4 lines · Jakub Narebski

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

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
#9 lore raw
Quoted 6 lines · Jakub Narebski
Quoted 1 line · Timo Hirvonen

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.

#10 lore raw
Quoted 4 lines · Junio C Hamano

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

#11 lore raw
In reply to Junio C Hamano
Quoted 3 lines · Junio C Hamano

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.

Signature · 3 lines
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git