summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 4be6096)
raw | patch | inline | side by side (parent: 4be6096)
author | Martin Waitz <tali@admingilde.org> | |
Sat, 16 Sep 2006 21:08:32 +0000 (23:08 +0200) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Sun, 17 Sep 2006 08:54:13 +0000 (01:54 -0700) |
Now three types of path based URLs are supported:
gitweb.cgi/project.git
gitweb.cgi/project.git/branch
gitweb.cgi/project.git/branch/filename
The first one (show project summary) was already supported for a long time
now. The other two are new: they show the shortlog of a branch or
the plain file contents of some file contained in the repository.
This is especially useful to support project web pages for small
projects: just create an html branch and then use an URL like
gitweb.cgi/project.git/html/index.html.
Signed-off-by: Martin Waitz <tali@admingilde.org>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb.cgi/project.git
gitweb.cgi/project.git/branch
gitweb.cgi/project.git/branch/filename
The first one (show project summary) was already supported for a long time
now. The other two are new: they show the shortlog of a branch or
the plain file contents of some file contained in the repository.
This is especially useful to support project web pages for small
projects: just create an html branch and then use an URL like
gitweb.cgi/project.git/html/index.html.
Signed-off-by: Martin Waitz <tali@admingilde.org>
Acked-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
gitweb/gitweb.perl | patch | blob | history |
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index a81c8d4cf2d605232ae49aed36c3b8bd0f7ccfee..645ae795c753a64b08fdd92b1d6c1aab03cbae53 100755 (executable)
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
}
}
-our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
-if (defined $project) {
- $project =~ s|^/||;
- $project =~ s|/$||;
- $project = undef unless $project;
-}
+our $project = $cgi->param('p');
if (defined $project) {
if (!validate_input($project)) {
die_error(undef, "Invalid project parameter");
if (!(-e "$projectroot/$project/HEAD")) {
die_error(undef, "No such project");
}
- $git_dir = "$projectroot/$project";
}
our $file_name = $cgi->param('f');
$searchtext = quotemeta $searchtext;
}
+# now read PATH_INFO and use it as alternative to parameters
+our $path_info = $ENV{"PATH_INFO"};
+$path_info =~ s|^/||;
+$path_info =~ s|/$||;
+if (validate_input($path_info) && !defined $project) {
+ $project = $path_info;
+ while ($project && !-e "$projectroot/$project/HEAD") {
+ $project =~ s,/*[^/]*$,,;
+ }
+ if (defined $project) {
+ $project = undef unless $project;
+ }
+ if ($path_info =~ m,^$project/([^/]+)/(.+)$,) {
+ # we got "project.git/branch/filename"
+ $action ||= "blob_plain";
+ $hash_base ||= $1;
+ $file_name ||= $2;
+ } elsif ($path_info =~ m,^$project/([^/]+)$,) {
+ # we got "project.git/branch"
+ $action ||= "shortlog";
+ $hash ||= $1;
+ }
+}
+
+$git_dir = "$projectroot/$project";
+
# dispatch
my %actions = (
"blame" => \&git_blame2,