]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: fallback to system-wide config file if default config does not exist
authorGerrit Pape <redacted>
Wed, 26 Mar 2008 18:11:19 +0000 (18:11 +0000)
committerLady <redacted>
Mon, 6 Apr 2026 04:07:12 +0000 (00:07 -0400)
From a distribution point of view, configuration files for applications
should reside in /etc/.  On the other hand it's convenient for multiple
instances of gitweb (e.g. virtual web servers on a single machine) to have
a per-instance configuration file, just as gitweb currently supports
through the file gitweb_config.perl next to the cgi.

To support both at runtime, this commit introduces GITWEB_CONFIG_SYSTEM as
a system-wide configuration file which will be used as a fallback if the
config file sprecified throug GITWEB_CONFIG does not exist.

See also
 http://bugs.debian.org/450592

Signed-off-by: Gerrit Pape <redacted>
Acked-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
INSTALL
README
gitweb.perl

diff --git a/INSTALL b/INSTALL
index 69bc9a466f4e3bc564f2a5bafac35fba5a42ba2023d9cbbef511d2e31a6afda5..0dfde847b5d8ee9f214f99b5b0208a3e2090c152977572d179b8352e54efab6b 100644 (file)
--- a/INSTALL
+++ b/INSTALL
@@ -95,7 +95,11 @@ for gitweb (in gitweb/README).
   by default it is file named gitweb_config.perl in the same place as
   gitweb.cgi script. You can control default place for config file
   using GITWEB_CONFIG build configuration variable, and you can set it
-  using GITWEB_CONFIG environmental variable.
+  using GITWEB_CONFIG environmental variable. If this file does not
+  exist, gitweb looks for a system-wide configuration file, normally
+  /etc/gitweb.conf. You can change the default using the
+  GITWEB_CONFIG_SYSTEM build configuration variable, and override it
+  through GITWEB_CONFIG_SYSTEM environmental variable.
 
 - Gitweb config file is [fragment] of perl code. You can set variables
   using "our $variable = value"; text from "#" character until the end
diff --git a/README b/README
index 0c7d7ea2ce25b43e8ecb5626aa47ecb8d84720a9feb75256dda97e67d14ce49f..07c94fcd63dc1cd6c2fccf24bfa03d044ac0ac1bfba0fa8cfaa8d55df2ead1a9 100644 (file)
--- a/README
+++ b/README
@@ -100,12 +100,19 @@ You can specify the following configuration variables when building GIT:
    is set when gitweb.cgi is executed, then the file specified in the
    environment variable will be loaded instead of the file specified
    when gitweb.cgi was created.  [Default: gitweb_config.perl]
+ * GITWEB_CONFIG_SYSTEM
+   This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG
+   does not exist.  If the environment variable GITWEB_CONFIG_SYSTEM is set
+   when gitweb.cgi is executed, then the file specified in the environment
+   variable will be loaded instead of the file specified when gitweb.cgi was
+   created.  [Default: /etc/gitweb.conf]
 
 Runtime gitweb configuration
 ----------------------------
 
 You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
-(defaults to 'gitweb_config.perl' in the same directory as the CGI).
+(defaults to 'gitweb_config.perl' in the same directory as the CGI), and
+as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
 The most notable thing that is not configurable at compile time are the
 optional features, stored in the '%features' variable.
 
index e68122ea6853534e5a3968ae710e28a087667f9cb3a06440dd21450a212ac4bb..348c2d67a88a466b9283f3b9674279348fb40cb9def589b4f813202d03b9ec99 100755 (executable)
@@ -370,7 +370,12 @@ sub filter_snapshot_fmts {
 }
 
 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
-do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
+if (-e $GITWEB_CONFIG) {
+       do $GITWEB_CONFIG;
+} else {
+       our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
+       do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;
+}
 
 # version of the core git binary
 our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";
This page took 0.282082 seconds and 4 git commands to generate.