From: Martin Waitz <tali@admingilde.org>
To: git@vger.kernel.org
Subject: [PATCH] gitweb: more support for PATH_INFO based URLs
Date: Sat, 16 Sep 2006 23:08:32 +0200 [thread overview]
Message-ID: <20060916210832.GV17042@admingilde.org> (raw)
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>
---
gitweb/gitweb.perl | 34 +++++++++++++++++++++++++++-------
1 files changed, 27 insertions(+), 7 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 9324d71..2789657 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -171,12 +171,7 @@ if (defined $action) {
}
}
-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");
@@ -187,7 +182,6 @@ if (defined $project) {
if (!(-e "$projectroot/$project/HEAD")) {
die_error(undef, "No such project");
}
- $git_dir = "$projectroot/$project";
}
our $file_name = $cgi->param('f');
@@ -247,6 +241,32 @@ if (defined $searchtext) {
$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,
--
1.4.2.gb8b6b
--
Martin Waitz
next reply other threads:[~2006-09-16 21:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-16 21:08 Martin Waitz [this message]
2006-09-16 21:46 ` [PATCH] gitweb: more support for PATH_INFO based URLs Jakub Narebski
2006-09-17 12:14 ` [PATCH] gitweb: fix warnings from dd70235f5a81e (PATH_INFO) Matthias Lederhofer
2006-09-17 21:34 ` Junio C Hamano
2006-09-17 13:18 ` [PATCH] gitweb: more support for PATH_INFO based URLs Jakub Narebski
2006-09-17 14:20 ` Jakub Narebski
2006-09-19 8:19 ` Martin Waitz
2006-09-19 9:49 ` Jakub Narebski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060916210832.GV17042@admingilde.org \
--to=tali@admingilde.org \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.