Merge branch 'jn/maint-gitweb-dynconf'
authorJunio C Hamano <gitster@pobox.com>
Fri, 13 Aug 2010 01:32:31 +0000 (18:32 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Aug 2010 01:32:31 +0000 (18:32 -0700)
* jn/maint-gitweb-dynconf:
gitweb: allow configurations that change with each request

1  2 
gitweb/gitweb.perl
diff --combined gitweb/gitweb.perl
index 4efeebc2276e5532938c25a8eaa188590fbdb794,c1e910af6d95fb10366d246efbc724e987f01a3f..898b121b50f5a84cf2186fe547ea65a79728e21d
@@@ -232,29 -232,6 +232,29 @@@ our %avatar_size = 
  # Leave it undefined (or set to 'undef') to turn off load checking.
  our $maxload = 300;
  
 +# configuration for 'highlight' (http://www.andre-simon.de/)
 +# match by basename
 +our %highlight_basename = (
 +      #'Program' => 'py',
 +      #'Library' => 'py',
 +      'SConstruct' => 'py', # SCons equivalent of Makefile
 +      'Makefile' => 'make',
 +);
 +# match by extension
 +our %highlight_ext = (
 +      # main extensions, defining name of syntax;
 +      # see files in /usr/share/highlight/langDefs/ directory
 +      map { $_ => $_ }
 +              qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
 +      # alternate extensions, see /etc/highlight/filetypes.conf
 +      'h' => 'c',
 +      map { $_ => 'cpp' } qw(cxx c++ cc),
 +      map { $_ => 'php' } qw(php3 php4),
 +      map { $_ => 'pl'  } qw(perl pm), # perhaps also 'cgi'
 +      'mak' => 'make',
 +      map { $_ => 'xml' } qw(xhtml html htm),
 +);
 +
  # You define site-wide feature defaults here; override them with
  # $GITWEB_CONFIG as necessary.
  our %feature = (
@@@ -1060,8 -1037,12 +1060,12 @@@ sub run_request 
        reset_timer();
  
        evaluate_uri();
+       evaluate_gitweb_config();
        check_loadavg();
  
+       # $projectroot and $projects_list might be set in gitweb config file
+       $projects_list ||= $projectroot;
        evaluate_query_params();
        evaluate_path_info();
        evaluate_and_validate_params();
@@@ -1109,12 -1090,8 +1113,8 @@@ sub evaluate_argv 
  
  sub run {
        evaluate_argv();
-       evaluate_gitweb_config();
        evaluate_git_version();
  
-       # $projectroot and $projects_list might be set in gitweb config file
-       $projects_list ||= $projectroot;
        $pre_listen_hook->()
                if $pre_listen_hook;
  
  
                run_request();
  
 -              $pre_dispatch_hook->()
 +              $post_dispatch_hook->()
                        if $post_dispatch_hook;
  
                last REQUEST if ($is_last_request->());
@@@ -3339,6 -3316,30 +3339,6 @@@ sub blob_contenttype 
  sub guess_file_syntax {
        my ($highlight, $mimetype, $file_name) = @_;
        return undef unless ($highlight && defined $file_name);
 -
 -      # configuration for 'highlight' (http://www.andre-simon.de/)
 -      # match by basename
 -      my %highlight_basename = (
 -              #'Program' => 'py',
 -              #'Library' => 'py',
 -              'SConstruct' => 'py', # SCons equivalent of Makefile
 -              'Makefile' => 'make',
 -      );
 -      # match by extension
 -      my %highlight_ext = (
 -              # main extensions, defining name of syntax;
 -              # see files in /usr/share/highlight/langDefs/ directory
 -              map { $_ => $_ }
 -                      qw(py c cpp rb java css php sh pl js tex bib xml awk bat ini spec tcl),
 -              # alternate extensions, see /etc/highlight/filetypes.conf
 -              'h' => 'c',
 -              map { $_ => 'cpp' } qw(cxx c++ cc),
 -              map { $_ => 'php' } qw(php3 php4),
 -              map { $_ => 'pl'  } qw(perl pm), # perhaps also 'cgi'
 -              'mak' => 'make',
 -              map { $_ => 'xml' } qw(xhtml html htm),
 -      );
 -
        my $basename = basename($file_name, '.in');
        return $highlight_basename{$basename}
                if exists $highlight_basename{$basename};
@@@ -6521,13 -6522,12 +6521,13 @@@ sub git_search 
                        $paging_nav .= " &sdot; next";
                }
  
 -              if ($#commitlist >= 100) {
 -              }
 -
                git_print_page_nav('','', $hash,$co{'tree'},$hash, $paging_nav);
                git_print_header_div('commit', esc_html($co{'title'}), $hash);
 -              git_search_grep_body(\@commitlist, 0, 99, $next_link);
 +              if ($page == 0 && !@commitlist) {
 +                      print "<p>No match.</p>\n";
 +              } else {
 +                      git_search_grep_body(\@commitlist, 0, 99, $next_link);
 +              }
        }
  
        if ($searchtype eq 'pickaxe') {