Skip to contentSkip to conversation

add conf file support to gitweb

PATCH Andres Salomon 1 participant 1 message Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hi,

The attached patch makes gitweb read and eval variables from an /etc/gitweb.conf file. This is useful for distributions; I'm packaging gitweb for debian, and want to have a separate config file that users can edit that won't get overwritten when they upgrade gitweb. Even if you don't take this patch, please consider some other method that decouples the configuration from the gitweb.cgi script.

gitweb.cgi (mode:100755) renamed from gitweb.cgi (mode:100644) +10 -0
Index: gitweb.cgi
===================================================================
@@ -40,6 +40,16 @@
 #my $projects_list = $projectroot;
 my $projects_list = "index/index.aux";
 
+# allow config file to override settings above
+if (-r '/etc/gitweb.conf') {
+	open(CONF, '/etc/gitweb.conf') || die_error(undef, "Cannot open /etc/gitweb.conf.");
+	while (<CONF>) {
+		chomp;
+		eval($_) if ($_ =~ /^\s*(\$[\w]+)\s*=\s*(.*)\s*$/);
+	}
+	close(CONF);
+}
+
 # input validation and dispatch
 my $action = $cgi->param('a');
 if (defined $action) {