From: Jakub Narebski <jnareb@gmail.com>
To: git@vger.kernel.org
Subject: [PATCH 3/3] gitweb: Route rest of action subroutines through %actions
Date: Tue, 22 Aug 2006 16:59:20 +0200 [thread overview]
Message-ID: <200608221659.20655.jnareb@gmail.com> (raw)
In-Reply-To: <200608221651.19629.jnareb@gmail.com>
Route rest of action subroutines, namely git_project_list and git_opml
(both of which doesn't need $project) through %actions hash.
This has disadvantage that all parameters are read and validated;
earlier git_opml was called as soon as $action was parsed and
validated, git_project_list was called as soon as $project was parsed
and validated. This has advantage that all action dispatch is grouped
in one place.
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is an alternative to (not accepted) patch by Martin Waitz from
in http://permalink.gmane.org/gmane.comp.version-control.git/25535
Message-Id: <11557673281583-git-send-email-tali@admingilde.org>
gitweb: use action dispatcher for non-project actions, too.
gitweb/gitweb.perl | 17 ++++++++---------
1 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index f59213e..e09204d 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -155,11 +155,6 @@ if (defined $action) {
if ($action =~ m/[^0-9a-zA-Z\.\-_]/) {
die_error(undef, "Invalid action parameter");
}
- # action which does not check rest of parameters
- if ($action eq "opml") {
- git_opml();
- exit;
- }
}
our $project = ($cgi->param('p') || $ENV{'PATH_INFO'});
@@ -179,9 +174,6 @@ if (defined $project) {
die_error(undef, "No such project");
}
$ENV{'GIT_DIR'} = "$projectroot/$project";
-} else {
- git_project_list();
- exit;
}
our $file_name = $cgi->param('f');
@@ -255,9 +247,16 @@ my %actions = (
"tags" => \&git_tags,
"tree" => \&git_tree,
"snapshot" => \&git_snapshot,
+ # those below don't need $project
+ "opml" => \&git_opml,
+ "project_list" => \&git_project_list,
);
-$action = 'summary' if (!defined($action));
+if (defined $project) {
+ $action ||= 'summary';
+} else {
+ $action ||= 'project_list';
+}
if (!defined($actions{$action})) {
die_error(undef, "Unknown action");
}
--
1.4.1.1
next prev parent reply other threads:[~2006-08-22 14:59 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-22 14:51 [PATCH 0/3] gitweb: Yet another cleanup series Jakub Narebski
2006-08-22 14:52 ` [PATCH 1/3] gitweb: Whitespace cleanup: realign, reindent Jakub Narebski
2006-08-23 1:34 ` Junio C Hamano
2006-08-23 8:55 ` Jakub Narebski
2006-08-23 9:07 ` Andreas Ericsson
2006-08-23 9:55 ` Junio C Hamano
2006-08-22 14:55 ` [PATCH 2/3] gitweb: Use underscore instead of hyphen to separate words in HTTP headers names Jakub Narebski
2006-08-22 14:59 ` Jakub Narebski [this message]
2006-08-22 15:03 ` [PATCH 0/3] gitweb: Yet another cleanup series Jakub Narebski
2006-08-22 21:42 ` [PATCH 4/3] gitweb: Use here-doc Jakub Narebski
2006-08-22 21:54 ` Jakub Narebski
2006-08-23 1:34 ` Junio C Hamano
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=200608221659.20655.jnareb@gmail.com \
--to=jnareb@gmail.com \
--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.