gitweb: Introduce common system-wide settings for convenience
Because of backward compatibility we cannot change gitweb to always use /etc/gitweb.conf (i.e. even if gitweb_config.perl exists). For common system-wide settings we therefore need separate configuration file: /etc/gitweb-common.conf. Long description: gitweb currently obtains configuration from the following sources: 1. per-instance configuration file (default: gitweb_conf.perl) 2. system-wide configuration file (default: /etc/gitweb.conf) If per-instance configuration file exists, then system-wide configuration is _not used at all_. This is quite untypical and suprising behavior. Moreover it is different from way git itself treats /etc/git.conf. It reads in stuff from /etc/git.conf and then local repos can change or override things as needed. In fact this is quite beneficial, because it gives site admins a simple and easy way to give an automatic hint to a repo about things the admin would like. On the other hand changing current behavior may lead to the situation, where something in /etc/gitweb.conf may interfere with unintended interaction in the local repository. One solution would be to _require_ to do explicit include; with read_config_file() it is now easy, as described in gitweb/README (description introduced in this commit). But as J.H. noticed we cannot ask people to modify their per-instance gitweb config file to include system-wide settings, nor we can require them to do this. Therefore, as proposed by Junio, for gitweb to have centralized config elements while retaining backwards compatibility, introduce separate common system-wide configuration file, by default /etc/gitweb-common.conf Noticed-by: Drew Northup <drew.northup@maine.edu> Helped-by: John 'Warthog9' Hawley <warthog9@kernel.org> Inspired-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Jakub Narebski <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f696543dad
commit
131d6afcba
@ -661,13 +661,25 @@ sub read_config_file {
|
||||
return;
|
||||
}
|
||||
|
||||
our ($GITWEB_CONFIG, $GITWEB_CONFIG_SYSTEM);
|
||||
our ($GITWEB_CONFIG, $GITWEB_CONFIG_SYSTEM, $GITWEB_CONFIG_COMMON);
|
||||
sub evaluate_gitweb_config {
|
||||
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
|
||||
our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
|
||||
our $GITWEB_CONFIG_COMMON = $ENV{'GITWEB_CONFIG_COMMON'} || "++GITWEB_CONFIG_COMMON++";
|
||||
|
||||
# use first config file that exists
|
||||
read_config_file($GITWEB_CONFIG) or
|
||||
# Protect agains duplications of file names, to not read config twice.
|
||||
# Only one of $GITWEB_CONFIG and $GITWEB_CONFIG_SYSTEM is used, so
|
||||
# there possibility of duplication of filename there doesn't matter.
|
||||
$GITWEB_CONFIG = "" if ($GITWEB_CONFIG eq $GITWEB_CONFIG_COMMON);
|
||||
$GITWEB_CONFIG_SYSTEM = "" if ($GITWEB_CONFIG_SYSTEM eq $GITWEB_CONFIG_COMMON);
|
||||
|
||||
# Common system-wide settings for convenience.
|
||||
# Those settings can be ovverriden by GITWEB_CONFIG or GITWEB_CONFIG_SYSTEM.
|
||||
read_config_file($GITWEB_CONFIG_COMMON);
|
||||
|
||||
# Use first config file that exists. This means use the per-instance
|
||||
# GITWEB_CONFIG if exists, otherwise use GITWEB_SYSTEM_CONFIG.
|
||||
read_config_file($GITWEB_CONFIG) and return;
|
||||
read_config_file($GITWEB_CONFIG_SYSTEM);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user