Merge branch 'maint'
authorJunio C Hamano <gitster@pobox.com>
Tue, 2 Mar 2010 20:44:16 +0000 (12:44 -0800)
committerJunio C Hamano <gitster@pobox.com>
Tue, 2 Mar 2010 20:44:16 +0000 (12:44 -0800)
* maint:
gitweb: Fix project-specific feature override behavior
gitweb multiple project roots documentation

1  2 
gitweb/gitweb.perl
diff --combined gitweb/gitweb.perl
index 32b04a469e0d3fb824bdcd604fb7051925be62b3,0b1e357ce9592e87b924333cc9a414f29a5fa886..a2d2283ec921acac7b068537eb85f63c16de9556
@@@ -454,7 -454,11 +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;
@@@ -550,14 -554,11 +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.
@@@ -1146,7 -1147,6 +1150,7 @@@ sub validate_refname 
  # in utf-8 thanks to "binmode STDOUT, ':utf8'" at beginning
  sub to_utf8 {
        my $str = shift;
 +      return undef unless defined $str;
        if (utf8::valid($str)) {
                utf8::decode($str);
                return $str;
  # correct, but quoted slashes look too horrible in bookmarks
  sub esc_param {
        my $str = shift;
 +      return undef unless defined $str;
        $str =~ s/([^A-Za-z0-9\-_.~()\/:@ ]+)/CGI::escape($1)/eg;
        $str =~ s/ /\+/g;
        return $str;
  # quote unsafe chars in whole URL, so some charactrs cannot be quoted
  sub esc_url {
        my $str = shift;
 +      return undef unless defined $str;
        $str =~ s/([^A-Za-z0-9\-_.~();\/;?:@&=])/sprintf("%%%02X", ord($1))/eg;
        $str =~ s/\+/%2B/g;
        $str =~ s/ /\+/g;
@@@ -1180,8 -1178,6 +1184,8 @@@ sub esc_html 
        my $str = shift;
        my %opts = @_;
  
 +      return undef unless defined $str;
 +
        $str = to_utf8($str);
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
@@@ -1196,8 -1192,6 +1200,8 @@@ sub esc_path 
        my $str = shift;
        my %opts = @_;
  
 +      return undef unless defined $str;
 +
        $str = to_utf8($str);
        $str = $cgi->escapeHTML($str);
        if ($opts{'-nbsp'}) {
@@@ -2212,6 -2206,9 +2216,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\.//;
@@@ -3382,7 -3379,7 +3389,7 @@@ sub git_footer_html 
              "</html>";
  }
  
 -# die_error(<http_status_code>, <error_message>)
 +# die_error(<http_status_code>, <error_message>[, <detailed_html_description>])
  # Example: die_error(404, 'Hash not found')
  # By convention, use the following status codes (as defined in RFC 2616):
  # 400: Invalid or missing CGI parameters, or
  #      or down for maintenance).  Generally, this is a temporary state.
  sub die_error {
        my $status = shift || 500;
 -      my $error = shift || "Internal server error";
 +      my $error = esc_html(shift) || "Internal Server Error";
        my $extra = shift;
  
        my %http_responses = (