Skip to content

Commit 018465d

Browse files
committed
Merge branch 'gp/gitweb'
* gp/gitweb: gitweb: fallback to system-wide config file (fixup) gitweb: fallback to system-wide config file if default config does not exist
2 parents 3c993de + 26ffcb7 commit 018465d

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ ETC_GITCONFIG = $(sysconfdir)/gitconfig
189189

190190
# default configuration for gitweb
191191
GITWEB_CONFIG = gitweb_config.perl
192+
GITWEB_CONFIG_SYSTEM = /etc/gitweb.conf
192193
GITWEB_HOME_LINK_STR = projects
193194
GITWEB_SITENAME =
194195
GITWEB_PROJECTROOT = /pub/git
@@ -1034,6 +1035,7 @@ gitweb/gitweb.cgi: gitweb/gitweb.perl
10341035
-e 's|++GIT_VERSION++|$(GIT_VERSION)|g' \
10351036
-e 's|++GIT_BINDIR++|$(bindir)|g' \
10361037
-e 's|++GITWEB_CONFIG++|$(GITWEB_CONFIG)|g' \
1038+
-e 's|++GITWEB_CONFIG_SYSTEM++|$(GITWEB_CONFIG_SYSTEM)|g' \
10371039
-e 's|++GITWEB_HOME_LINK_STR++|$(GITWEB_HOME_LINK_STR)|g' \
10381040
-e 's|++GITWEB_SITENAME++|$(GITWEB_SITENAME)|g' \
10391041
-e 's|++GITWEB_PROJECTROOT++|$(GITWEB_PROJECTROOT)|g' \

gitweb/INSTALL

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,11 @@ for gitweb (in gitweb/README).
9595
by default it is file named gitweb_config.perl in the same place as
9696
gitweb.cgi script. You can control default place for config file
9797
using GITWEB_CONFIG build configuration variable, and you can set it
98-
using GITWEB_CONFIG environmental variable.
98+
using GITWEB_CONFIG environmental variable. If this file does not
99+
exist, gitweb looks for a system-wide configuration file, normally
100+
/etc/gitweb.conf. You can change the default using the
101+
GITWEB_CONFIG_SYSTEM build configuration variable, and override it
102+
through GITWEB_CONFIG_SYSTEM environmental variable.
99103

100104
- Gitweb config file is [fragment] of perl code. You can set variables
101105
using "our $variable = value"; text from "#" character until the end

gitweb/README

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,20 @@ You can specify the following configuration variables when building GIT:
100100
is set when gitweb.cgi is executed, then the file specified in the
101101
environment variable will be loaded instead of the file specified
102102
when gitweb.cgi was created. [Default: gitweb_config.perl]
103+
* GITWEB_CONFIG_SYSTEM
104+
This Perl file will be loaded using 'do' as a fallback if GITWEB_CONFIG
105+
does not exist. If the environment variable GITWEB_CONFIG_SYSTEM is set
106+
when gitweb.cgi is executed, then the file specified in the environment
107+
variable will be loaded instead of the file specified when gitweb.cgi was
108+
created. [Default: /etc/gitweb.conf]
103109

104110

105111
Runtime gitweb configuration
106112
----------------------------
107113

108114
You can adjust gitweb behaviour using the file specified in `GITWEB_CONFIG`
109-
(defaults to 'gitweb_config.perl' in the same directory as the CGI).
115+
(defaults to 'gitweb_config.perl' in the same directory as the CGI), and
116+
as a fallback `GITWEB_CONFIG_SYSTEM` (defaults to /etc/gitweb.conf).
110117
The most notable thing that is not configurable at compile time are the
111118
optional features, stored in the '%features' variable.
112119

gitweb/gitweb.perl

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,12 @@ sub filter_snapshot_fmts {
369369
}
370370

371371
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
372-
do $GITWEB_CONFIG if -e $GITWEB_CONFIG;
372+
if (-e $GITWEB_CONFIG) {
373+
do $GITWEB_CONFIG;
374+
} else {
375+
our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
376+
do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;
377+
}
373378

374379
# version of the core git binary
375380
our $git_version = qx($GIT --version) =~ m/git version (.*)$/ ? $1 : "unknown";

0 commit comments

Comments
 (0)