]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Improve behavior for actionless path_info gitweb URLs
authorJakub Narebski <redacted>
Wed, 13 Oct 2010 11:35:20 +0000 (13:35 +0200)
committerLady <redacted>
Mon, 6 Apr 2026 04:51:30 +0000 (00:51 -0400)
Eli Barzilay noticed that

  http://server/gitweb/project/<commit-sha1>

link goes to 'shortlog' view, while 'commit' view would be more
useful, but that 'shortlog' action is more apropriate for

  http://server/gitweb/project/<commit-sha1>..<other-commit-sha1>

links.

Therefore for the case when we don't have either action, or filename,
or parent hash [base] in path_info-based URL, i.e. for

  http://server/gitweb/project/<object-id>

link, instead of using 'shortlog' view we allow dispatch() subroutine
to detect type of object and use appropriate action (in most case it
would be either 'commit' action, or 'tag', or 'tree' for top
directory).

Requested-by: Eli Barzilay <redacted>
Signed-off-by: Jakub Narebski <redacted>
Tested-by: Eli Barzilay <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index df186d8d2a107ef28ad8ca7e3724963b6519db39b4c90d64b416d9a23508d1a5..2a73955e8db0133a6b35da4edd3baee1a9095a4b57273685eb94291beac0580c 100755 (executable)
@@ -821,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.
-               $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;
This page took 0.271962 seconds and 4 git commands to generate.