Merge branch 'jn/gitweb-config-error-die' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 5 Mar 2010 06:27:12 +0000 (22:27 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 5 Mar 2010 06:27:12 +0000 (22:27 -0800)
* jn/gitweb-config-error-die:
gitweb: Die if there are parsing errors in config file

1  2 
gitweb/gitweb.perl
diff --combined gitweb/gitweb.perl
index 0b1e357ce9592e87b924333cc9a414f29a5fa886,20106a4f42b02d4e20a25617f3725f9c1f9b7055..3d80deba01696f7d039955da68daac9e61507420
@@@ -454,11 -454,7 +454,11 @@@ sub gitweb_get_feature 
                $feature{$name}{'sub'},
                $feature{$name}{'override'},
                @{$feature{$name}{'default'}});
 -      if (!$override) { return @defaults; }
 +      # project specific override is possible only if we have project
 +      our $git_dir; # global variable, declared later
 +      if (!$override || !defined $git_dir) {
 +              return @defaults;
 +      }
        if (!defined $sub) {
                warn "feature $name is not overridable";
                return @defaults;
@@@ -554,11 -550,14 +554,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.
@@@ -2206,9 -2205,6 +2209,9 @@@ sub config_to_multi 
  sub git_get_project_config {
        my ($key, $type) = @_;
  
 +      # do we have project
 +      return unless (defined $project && defined $git_dir);
 +
        # key sanity check
        return unless ($key);
        $key =~ s/^gitweb\.//;