git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Die if there are parsing errors in config file
@ 2010-02-07  9:40 Jakub Narebski
  2010-02-07 10:53 ` J.H.
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Jakub Narebski @ 2010-02-07  9:40 UTC (permalink / raw)
  To: git; +Cc: 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 do` documentation.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
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(-)

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 $@;
 
 # Get loadavg of system, to compare against $maxload.
 # Currently it requires '/proc/loadavg' present to get loadavg;

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] gitweb: Die if there are parsing errors in config file
  2010-02-07  9:40 [PATCH] gitweb: Die if there are parsing errors in config file Jakub Narebski
@ 2010-02-07 10:53 ` J.H.
  2010-02-08  8:48   ` Jakub Narebski
  2010-02-13  2:46 ` Jakub Narebski
  2010-02-14 21:17 ` Junio C Hamano
  2 siblings, 1 reply; 6+ messages in thread
From: J.H. @ 2010-02-07 10:53 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

I'd sign-off that, I've probably run into it a couple of times myself.

- John 'Warthog9' Hawley

On 02/07/2010 01:40 AM, Jakub Narebski wrote:
> 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.
> 
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> ---
> 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(-)
> 
> 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 $@;
>  
>  # 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 majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gitweb: Die if there are parsing errors in config file
  2010-02-07 10:53 ` J.H.
@ 2010-02-08  8:48   ` Jakub Narebski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Narebski @ 2010-02-08  8:48 UTC (permalink / raw)
  To: J.H.; +Cc: git

On Sun, 7 Feb 2010, J.H. wrote:

> 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...
 
> On 02/07/2010 01:40 AM, Jakub Narebski wrote:
> > 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.
> > 
> > Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> > ---
> > 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.
[...]

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gitweb: Die if there are parsing errors in config file
  2010-02-07  9:40 [PATCH] gitweb: Die if there are parsing errors in config file Jakub Narebski
  2010-02-07 10:53 ` J.H.
@ 2010-02-13  2:46 ` Jakub Narebski
  2010-02-14 21:17 ` Junio C Hamano
  2 siblings, 0 replies; 6+ messages in thread
From: Jakub Narebski @ 2010-02-13  2:46 UTC (permalink / raw)
  To: git; +Cc: Junio Hamano

Ping!

I didn't want to push for it before 1.7.0, but now that 1.7.0
is out...

On Sun, 7 Feb 2010, Jakub Narebski wrote:
> 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.
> 
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
  Acked-by: John 'Warthog9' Hawley <warthog9@kernel.org>

http://thread.gmane.org/gmane.comp.version-control.git/139226/focus=139230

> ---
> 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(-)
> 
> 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 $@;
>  
>  # Get loadavg of system, to compare against $maxload.
>  # Currently it requires '/proc/loadavg' present to get loadavg;
> 
> 

-- 
Jakub Narebski
Poland

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gitweb: Die if there are parsing errors in config file
  2010-02-07  9:40 [PATCH] gitweb: Die if there are parsing errors in config file Jakub Narebski
  2010-02-07 10:53 ` J.H.
  2010-02-13  2:46 ` Jakub Narebski
@ 2010-02-14 21:17 ` Junio C Hamano
  2010-02-14 21:46   ` Jakub Narebski
  2 siblings, 1 reply; 6+ messages in thread
From: Junio C Hamano @ 2010-02-14 21:17 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

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?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] gitweb: Die if there are parsing errors in config file
  2010-02-14 21:17 ` Junio C Hamano
@ 2010-02-14 21:46   ` Jakub Narebski
  0 siblings, 0 replies; 6+ messages in thread
From: Jakub Narebski @ 2010-02-14 21:46 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, J.H.

Dnia niedziela 14. lutego 2010 22:17, Junio C Hamano napisał:
> 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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2010-02-14 21:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-02-07  9:40 [PATCH] gitweb: Die if there are parsing errors in config file Jakub Narebski
2010-02-07 10:53 ` J.H.
2010-02-08  8:48   ` Jakub Narebski
2010-02-13  2:46 ` Jakub Narebski
2010-02-14 21:17 ` Junio C Hamano
2010-02-14 21:46   ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).