]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Die if there are parsing errors in config file
authorJakub Narebski <redacted>
Sun, 14 Feb 2010 21:46:28 +0000 (22:46 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:39 +0000 (00:50 -0400)
Otherwise the errors can propagate, and show in damnest places, and
you would spend your time chasing ghosts instead of debugging real
problem (yes, it is from personal experience).

This follows (parts of) advice in `perldoc -f do` documentation.

This required restructoring code a bit, so we die only if we are reading
(executing) config file.  As a side effect $GITWEB_CONFIG_SYSTEM is always
available, even when we use $GITWEB_CONFIG.

Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 8d6a7e94d1180299a8b68ea9af34be23b6d057ae2b18412cf994e5406c66c7c9..384a68ebe1ac784b7bb276982b53258b74cb85dc39c4af72bddaded7ad2f739d 100755 (executable)
@@ -551,11 +551,14 @@ sub filter_snapshot_fmts {
 }
 
 our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
+our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
+# die if there are errors parsing config file
 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;
+       die $@ if $@;
+} elsif (-e $GITWEB_CONFIG_SYSTEM) {
+       do $GITWEB_CONFIG_SYSTEM;
+       die $@ if $@;
 }
 
 # Get loadavg of system, to compare against $maxload.
This page took 0.337643 seconds and 4 git commands to generate.