gitweb: Die if there are parsing errors in config file
PATCH 1/1 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 is fallout from my work on [split] "Gitweb output caching" series. Before I used `die $@ if $@;' in t/t9503/test_cache_interface.pl, tests failed for no discernable reason...
So I think the same should be done for the gitweb config file.
gitweb/gitweb.perl | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
gitweb/gitweb.perl +2 -0
@@ -556,6 +556,8 @@ if (-e $GITWEB_CONFIG) { our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++"; do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; } +# die if there are errors parsing config file +die $@ if $@; # Get loadavg of system, to compare against $maxload. # Currently it requires '/proc/loadavg' present to get loadavg;
I'd sign-off that, I've probably run into it a couple of times myself.
- John 'Warthog9' Hawley
Quoted 35 lines · Jakub Narebski
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 dodocumentation.Signed-off-by Jakub Narebski <[email protected]>---
This is fallout from my work on [split] "Gitweb output caching" series. Before I used `die $@ if $@;' int/t9503/test_cache_interface.pl, tests failed for no discernable reason...So I think the same should be done for the gitweb config file.
gitweb/gitweb.perl | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)gitweb/gitweb.perl +2
-1@@ -556,6 +556,8 @@ if (-e $GITWEB_CONFIG) { our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++"; do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; } +# die if there are errors parsing config file +die $@ if $@; # Get loadavg of system, to compare against $maxload. # Currently it requires '/proc/loadavg' present to get loadavg; --To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 3 lines · J.H.
I'd sign-off that, I've probably run into it a couple of times myself.
- John 'Warthog9' Hawley
I think you meant ACK, not sign-off...
Quoted 14 lines · Jakub Narebski
Quoted 13 lines
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 dodocumentation.Signed-off-by Jakub Narebski <[email protected]>---
This is fallout from my work on [split] "Gitweb output caching" series. Before I used `die $@ if $@;' int/t9503/test_cache_interface.pl, tests failed for no discernable reason...So I think the same should be done for the gitweb config file.
[...]
Signature · 2 lines
Jakub Narebski Poland
Ping!
I didn't want to push for it before 1.7.0, but now that 1.7.0 is out...
Quoted 7 lines · Jakub Narebski
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 dodocumentation.Signed-off-by Jakub Narebski <[email protected]>
http://thread.gmane.org/gmane.comp.version-control.git/139226/focus=139230
Quoted 25 lines
---
This is fallout from my work on [split] "Gitweb output caching" series. Before I used `die $@ if $@;' int/t9503/test_cache_interface.pl, tests failed for no discernable reason...So I think the same should be done for the gitweb config file.
gitweb/gitweb.perl | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)gitweb/gitweb.perl +2
-0@@ -556,6 +556,8 @@ if (-e $GITWEB_CONFIG) { our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++"; do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; } +# die if there are errors parsing config file +die $@ if $@; # Get loadavg of system, to compare against $maxload. # Currently it requires '/proc/loadavg' present to get loadavg;
Signature · 2 lines
Jakub Narebski Poland
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 560
Quoted 10 lines · Jakub Narebski
gitweb/gitweb.perl +2
-0@@ -556,6 +556,8 @@ if (-e $GITWEB_CONFIG) { our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++"; do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; } +# die if there are errors parsing config file +die $@ if $@;
I cannot figure out $@ from which command this if statement modifier is checking when none of GITWEB_CONFIG or GITWEB_CONFIG_SYSTEM candidates is present. Neither of the "do" executes in such a case. Do you end up checking the result from the very first eval that checks if Time::HiRes can be "require"d successfully?
Quoted 18 lines · Junio C Hamano
gitweb/gitweb.perl if (-e $GITWEB_CONFIG) { · line 560
Quoted 10 lines · Jakub Narebski
gitweb/gitweb.perl +2
-0@@ -556,6 +556,8 @@ if (-e $GITWEB_CONFIG) { our $GITWEB_CONFIG_SYSTEM = $ENV{'GITWEB_CONFIG_SYSTEM'} || "++GITWEB_CONFIG_SYSTEM++"; do $GITWEB_CONFIG_SYSTEM if -e $GITWEB_CONFIG_SYSTEM; } +# die if there are errors parsing config file +die $@ if $@;I cannot figure out $@ from which command this if statement modifier is checking when none of
GITWEB_CONFIGorGITWEB_CONFIG_SYSTEMcandidates is present. Neither of the "do" executes in such a case. Do you end up checking the result from the very first eval that checks ifTime::HiRescan be "require"d successfully?
Good catch. There is corrected patch.
-- >8 --
Subject: [PATCH] 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.
---
gitweb/gitweb.perl | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
gitweb/gitweb.perl +6 -3
@@ -550,11 +550,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.
Signature · 1 line
1.6.6.1