git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] gitweb: Die if there are parsing errors in config file

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 14, 2010, 21:46 UTC
Message-ID
<201002142246.29478.jnareb@gmail.com>
In-Reply-To
<7v8wava55y.fsf@alter.siamese.dyndns.org>
Dnia niedziela 14. lutego 2010 22:17, Junio C Hamano napisał:
Show 18 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
> > diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
> > index 1f6978a..a5bc359 100755
> > --- a/gitweb/gitweb.perl
> > +++ b/gitweb/gitweb.perl
> > @@ -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?
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.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
Probably-Acked-by: John 'Warthog9' Hawley <warthog9@kernel.org>
 gitweb/gitweb.perl |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 1f6978a..20106a4 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -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.
-- 
1.6.6.1
Previous: Junio C Hamano
Message 6 of 6 in “gitweb: Die if there are parsing errors in config file”
  1. gitweb: Die if there are parsing errors in config fileJakub Narebski, Feb 7, 2010
  2. J.H.Feb 7, 2010
  3. Jakub NarebskiFeb 8, 2010
  4. Jakub NarebskiFeb 13, 2010
  5. Junio C HamanoFeb 14, 2010
  6. Jakub NarebskiFeb 14, 2010

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.