Skip to content

Commit d0af373

Browse files
jnarebgitster
authored andcommitted
gitweb: Improve behavior for actionless path_info gitweb URLs
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 <[email protected]> Signed-off-by: Jakub Narebski <[email protected]> Tested-by: Eli Barzilay <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e00dc5 commit d0af373

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

gitweb/gitweb.perl

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -819,8 +819,15 @@ sub evaluate_path_info {
819819
# hash_base instead. It should also be noted that hand-crafted
820820
# links having 'history' as an action and no pathname or hash
821821
# set will fail, but that happens regardless of PATH_INFO.
822-
$input_params{'action'} ||= "shortlog";
823-
if (grep { $_ eq $input_params{'action'} } @wants_base) {
822+
if (defined $parentrefname) {
823+
# if there is parent let the default be 'shortlog' action
824+
# (for http://git.example.com/repo.git/A..B links); if there
825+
# is no parent, dispatch will detect type of object and set
826+
# action appropriately if required (if action is not set)
827+
$input_params{'action'} ||= "shortlog";
828+
}
829+
if ($input_params{'action'} &&
830+
grep { $_ eq $input_params{'action'} } @wants_base) {
824831
$input_params{'hash_base'} ||= $refname;
825832
} else {
826833
$input_params{'hash'} ||= $refname;

0 commit comments

Comments
 (0)