summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTony Finch <dot@dotat.at>2015-03-19 15:39:59 +0000
committerJunio C Hamano <gitster@pobox.com>2015-03-19 13:44:07 -0700
commit423d356ddb8af2b3b64273902c2e538c2c4d6991 (patch)
tree90868c584ff8bd818477e2e17761e867c8319e0c
parent270f0a8cb2b3c00c5923844546c144c1233f9eb5 (diff)
downloadgit-423d356ddb8af2b3b64273902c2e538c2c4d6991.tar.gz
gitweb: if the PATH_INFO is incomplete, use it as a project_filter
Previously gitweb would ignore partial PATH_INFO. For example, it would produce a project list for the top URL https://www.example.org/projects/ and a project summary for https://www.example.org/projects/git/git.git but if you tried to list just the git-related projects with https://www.example.org/projects/git/ you would get a list of all projects, same as the top URL. As well as fixing that omission, this change also makes gitweb generate PATH_INFO-style URLs for project filter links, such as in the breadcrumbs. Signed-off-by: Tony Finch <dot@dotat.at> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rwxr-xr-xgitweb/gitweb.perl24
1 files changed, 23 insertions, 1 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a9f57d6f90..12aba8fe80 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -891,7 +891,17 @@ sub evaluate_path_info {
while ($project && !check_head_link("$projectroot/$project")) {
$project =~ s,/*[^/]*$,,;
}
- return unless $project;
+ # If there is no project, use the PATH_INFO as a project filter if it
+ # is a directory in the projectroot. (It can't be a subdirectory of a
+ # repo because we just verified that isn't the case.)
+ unless ($project) {
+ if (-d "$projectroot/$path_info") {
+ $path_info =~ s,/+$,,;
+ $input_params{'project_filter'} = $path_info;
+ $path_info = "";
+ }
+ return;
+ }
$input_params{'project'} = $project;
# do not change any parameters if an action is given using the query string
@@ -1356,6 +1366,18 @@ sub href {
}
my $use_pathinfo = gitweb_check_feature('pathinfo');
+
+ # we have to check for a project_filter first because handling the full
+ # project-plus-parameters deletes some of the paramaters we check here
+ if (!defined $params{'project'} && $params{'project_filter'} &&
+ $params{'action'} eq "project_list" &&
+ (exists $params{-path_info} ? $params{-path_info} : $use_pathinfo)) {
+ $href =~ s,/$,,;
+ $href .= "/".esc_path_info($params{'project_filter'})."/";
+ delete $params{'project_filter'};
+ delete $params{'action'};
+ }
+
if (defined $params{'project'} &&
(exists $params{-path_info} ? $params{-path_info} : $use_pathinfo)) {
# try to put as many parameters as possible in PATH_INFO: