]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jn/gitweb-test'
authorJunio C Hamano <gitster@pobox.com>
Wed, 17 Nov 2010 22:59:22 +0000 (14:59 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 17 Nov 2010 22:59:22 +0000 (14:59 -0800)
* jn/gitweb-test:
  gitweb/Makefile: Include gitweb/config.mak
  gitweb/Makefile: Add 'test' and 'test-installed' targets
  t/gitweb-lib.sh: Add support for GITWEB_TEST_INSTALLED
  gitweb: Move call to evaluate_git_version after evaluate_gitweb_config

1  2 
gitweb/Makefile
gitweb/gitweb.perl

diff --combined gitweb/Makefile
index e32ee76309606c82abcac483f8801968916047f2,df908a18ebe4e2eefea089b43956e88b58c48cff..0a6ac00631ed8eac5c20248a345074e4b8ff3707
@@@ -35,11 -35,11 +35,12 @@@ GITWEB_FAVICON = static/git-favicon.pn
  GITWEB_JS = static/gitweb.js
  GITWEB_SITE_HEADER =
  GITWEB_SITE_FOOTER =
 +HIGHLIGHT_BIN = highlight
  
  # include user config
  -include ../config.mak.autogen
  -include ../config.mak
+ -include config.mak
  
  # determine version
  ../GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
@@@ -130,8 -130,7 +131,8 @@@ GITWEB_REPLACE = 
        -e 's|++GITWEB_FAVICON++|$(GITWEB_FAVICON)|g' \
        -e 's|++GITWEB_JS++|$(GITWEB_JS)|g' \
        -e 's|++GITWEB_SITE_HEADER++|$(GITWEB_SITE_HEADER)|g' \
 -      -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g'
 +      -e 's|++GITWEB_SITE_FOOTER++|$(GITWEB_SITE_FOOTER)|g' \
 +      -e 's|++HIGHLIGHT_BIN++|$(HIGHLIGHT_BIN)|g'
  
  GITWEB-BUILD-OPTIONS: FORCE
        @rm -f $@+
@@@ -145,6 -144,15 +146,15 @@@ gitweb.cgi: gitweb.perl GITWEB-BUILD-OP
        chmod +x $@+ && \
        mv $@+ $@
  
+ ### Testing rules
+ test:
+       $(MAKE) -C ../t gitweb-test
+ test-installed:
+       GITWEB_TEST_INSTALLED='$(DESTDIR_SQ)$(gitwebdir_SQ)' \
+               $(MAKE) -C ../t gitweb-test
  ### Installation rules
  
  install: all
  clean:
        $(RM) gitweb.cgi static/gitweb.min.js static/gitweb.min.css GITWEB-BUILD-OPTIONS
  
- .PHONY: all clean install .FORCE-GIT-VERSION-FILE FORCE
+ .PHONY: all clean install test test-installed .FORCE-GIT-VERSION-FILE FORCE
  
diff --combined gitweb/gitweb.perl
index 253f41adc9e64105bf9d1642102b20bba6bc5f20,d521b4cf886cc9613848ebe78561e9e4a5fd7b18..679f2da3ee0c59413d34bf020e242887bfd4f28c
@@@ -7,7 -7,6 +7,7 @@@
  #
  # This program is licensed under the GPLv2
  
 +use 5.008;
  use strict;
  use warnings;
  use CGI qw(:standard :escapeHTML -nosticky);
@@@ -166,12 -165,6 +166,12 @@@ our @diff_opts = ('-M'); # taken from g
  # the gitweb domain.
  our $prevent_xss = 0;
  
 +# Path to the highlight executable to use (must be the one from
 +# http://www.andre-simon.de due to assumptions about parameters and output).
 +# Useful if highlight is not installed on your webserver's PATH.
 +# [Default: highlight]
 +our $highlight_bin = "++HIGHLIGHT_BIN++";
 +
  # information about snapshot formats that gitweb is capable of serving
  our %known_snapshot_formats = (
        # name => {
@@@ -781,10 -774,10 +781,10 @@@ sub evaluate_path_info 
                'history',
        );
  
 -      # we want to catch
 +      # we want to catch, among others
        # [$hash_parent_base[:$file_parent]..]$hash_parent[:$file_name]
        my ($parentrefname, $parentpathname, $refname, $pathname) =
 -              ($path_info =~ /^(?:(.+?)(?::(.+))?\.\.)?(.+?)(?::(.+))?$/);
 +              ($path_info =~ /^(?:(.+?)(?::(.+))?\.\.)?([^:]+?)?(?::(.+))?$/);
  
        # first, analyze the 'current' part
        if (defined $pathname) {
                # hash_base instead. It should also be noted that hand-crafted
                # links having 'history' as an action and no pathname or hash
                # set will fail, but that happens regardless of PATH_INFO.
 -              $input_params{'action'} ||= "shortlog";
 -              if (grep { $_ eq $input_params{'action'} } @wants_base) {
 +              if (defined $parentrefname) {
 +                      # if there is parent let the default be 'shortlog' action
 +                      # (for http://git.example.com/repo.git/A..B links); if there
 +                      # is no parent, dispatch will detect type of object and set
 +                      # action appropriately if required (if action is not set)
 +                      $input_params{'action'} ||= "shortlog";
 +              }
 +              if ($input_params{'action'} &&
 +                  grep { $_ eq $input_params{'action'} } @wants_base) {
                        $input_params{'hash_base'} ||= $refname;
                } else {
                        $input_params{'hash'} ||= $refname;
@@@ -1075,6 -1061,7 +1075,7 @@@ sub run_request 
  
        evaluate_uri();
        evaluate_gitweb_config();
+       evaluate_git_version();
        check_loadavg();
  
        # $projectroot and $projects_list might be set in gitweb config file
@@@ -1127,7 -1114,6 +1128,6 @@@ sub evaluate_argv 
  
  sub run {
        evaluate_argv();
-       evaluate_git_version();
  
        $pre_listen_hook->()
                if $pre_listen_hook;
@@@ -3374,8 -3360,7 +3374,8 @@@ sub run_highlighter 
        close $fd
                or die_error(404, "Reading blob failed");
        open $fd, quote_command(git_cmd(), "cat-file", "blob", $hash)." | ".
 -                "highlight --xhtml --fragment --syntax $syntax |"
 +                quote_command($highlight_bin).
 +                " --xhtml --fragment --syntax $syntax |"
                or die_error(500, "Couldn't open file or run syntax highlighter");
        return $fd;
  }