gitweb: Die if there are parsing errors in config file
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 <jnareb@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jakub Narebski committed
Feb 14, 2010 at 22:46 UTC
e6e592db4c0099a6412aed6e868769535900f112
1 file changed
+6
-3
gitweb/gitweb.perl
+6
-3
@@ -550,11 +550,14 @@ sub filter_snapshot_fmts {
550
}
551
552
our $GITWEB_CONFIG = $ENV{'GITWEB_CONFIG'} || "++GITWEB_CONFIG++";
553
+our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
554
+# die if there are errors parsing config file
555
if (-e $GITWEB_CONFIG) {
556
do $GITWEB_CONFIG;
555
-} else {
556
- our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++";
557
- do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM;
557
+ die $@ if $@;
558
+} elsif (-e $GITWEB_CONFIG_SYSTEM) {
559
+ do $GITWEB_CONFIG_SYSTEM;
560
+ die $@ if $@;
561
}
562
563
# Get loadavg of system, to compare against $maxload.