[RFD] gitweb configuration

7 messages, 4 authors, 2016-06-15 · open the first message on its own page

[RFD] gitweb configuration

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:42:30

Petr Baudis [off-list ref] 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

Re: [RFD] gitweb configuration

From: Petr Baudis <hidden>
Date: 2016-06-15 22:42:30

Dear diary, on Sun, Jun 18, 2006 at 12:48:12AM CEST, I got a letter
where Jakub Narebski [off-list ref] said that...
Petr Baudis [off-list ref] writes:
quoted
 - 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 <redacted>
---

 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.

Re: [RFD] gitweb configuration

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:42:30

Petr Baudis wrote:
quoted
- 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

Re: [RFD] gitweb configuration

From: Martin Langhoff <hidden>
Date: 2016-06-15 22:42:30

On 6/18/06, Jakub Narebski [off-list ref] 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

Re: [RFD] gitweb configuration

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:42:30

Martin Langhoff wrote:
On 6/18/06, Jakub Narebski [off-list ref] wrote:
quoted
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 [off-list ref] patch:
   http://marc.theaimsgroup.com/?l=git&m=114308224922372&w=2

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

Re: [RFD] gitweb configuration

From: Timo Hirvonen <hidden>
Date: 2016-06-15 22:42:30

Jakub Narebski [off-list ref] 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/

Re: [RFD] gitweb configuration

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:42:30

Timo Hirvonen wrote:
Jakub Narebski [off-list ref] wrote:
quoted
- 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help