Skip to content

Commit e6e592d

Browse files
jnarebgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e923eae commit e6e592d

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

gitweb/gitweb.perl

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,11 +550,14 @@ sub filter_snapshot_fmts {
550550
}
551551

552552
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
553555
if (-e $GITWEB_CONFIG) {
554556
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 $@;
558561
}
559562

560563
# Get loadavg of system, to compare against $maxload.

0 commit comments

Comments
 (0)