]> Lady’s Gitweb - Gitweb/blobdiff - gitweb.perl
gitweb: Improve behavior for actionless path_info gitweb URLs
[Gitweb] / gitweb.perl
index e6bbf787cbe59937decd6cf8dcaddbd73316cd58980830a13b8c805c1c91fd97..2a73955e8db0133a6b35da4edd3baee1a9095a4b57273685eb94291beac0580c 100755 (executable)
@@ -7,6 +7,7 @@
 #
 # This program is licensed under the GPLv2
 
 #
 # This program is licensed under the GPLv2
 
+use 5.008;
 use strict;
 use warnings;
 use CGI qw(:standard :escapeHTML -nosticky);
 use strict;
 use warnings;
 use CGI qw(:standard :escapeHTML -nosticky);
@@ -781,10 +782,10 @@ sub evaluate_path_info {
                'history',
        );
 
                '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) =
        # [$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) {
 
        # first, analyze the 'current' part
        if (defined $pathname) {
@@ -820,8 +821,15 @@ sub evaluate_path_info {
                # 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.
                # 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;
                        $input_params{'hash_base'} ||= $refname;
                } else {
                        $input_params{'hash'} ||= $refname;
@@ -1068,6 +1076,7 @@ sub run_request {
 
        evaluate_uri();
        evaluate_gitweb_config();
 
        evaluate_uri();
        evaluate_gitweb_config();
+       evaluate_git_version();
        check_loadavg();
 
        # $projectroot and $projects_list might be set in gitweb config file
        check_loadavg();
 
        # $projectroot and $projects_list might be set in gitweb config file
@@ -1120,7 +1129,6 @@ sub evaluate_argv {
 
 sub run {
        evaluate_argv();
 
 sub run {
        evaluate_argv();
-       evaluate_git_version();
 
        $pre_listen_hook->()
                if $pre_listen_hook;
 
        $pre_listen_hook->()
                if $pre_listen_hook;
This page took 0.278146 seconds and 4 git commands to generate.