From: Junio C Hamano Date: Wed, 17 Nov 2010 22:59:22 +0000 (-0800) Subject: Merge branch 'jn/gitweb-test' X-Git-Tag: v1.7.4-rc0~145 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/430fac9e5bdf24a2969f854ff0ff376140f88090?hp=-c Merge branch 'jn/gitweb-test' * 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 --- 430fac9e5bdf24a2969f854ff0ff376140f88090 diff --combined gitweb/Makefile index e32ee76309,df908a18eb..0a6ac00631 --- a/gitweb/Makefile +++ b/gitweb/Makefile @@@ -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 @@@ -158,5 -166,5 +168,5 @@@ 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 253f41adc9,d521b4cf88..679f2da3ee --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@@ -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) { @@@ -820,15 -813,8 +820,15 @@@ # 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; }