[PATCH] gitweb: new cgi parameter: option
From: Miklos Vajna <hidden>
Date: 2016-06-15 22:43:20
Subsystem:
the rest · Maintainer:
Linus Torvalds
Currently the only supported value is '--no-merges' for the 'rss', 'atom', 'log', 'shortlog' and 'history' actions, but it can be easily extended to allow other parameters for other actions. Signed-off-by: Miklos Vajna <redacted> --- Na Wed, Jul 11, 2007 at 11:19:41PM +0200, Jakub Narebski [off-list ref] pisal(a):
Miklos Vajna wrote:quoted
+((defined $filter and $filter == "nomerges") ? ("--no-merges") : ()),Shouldn't it be '$filter eq "nomerges"' instead?
Yes, that works too (I'm not a perl addict :) )
Besides, I'd rather have generalized way to provide additional options to git commands, like '--no-merges' for RSS and Atom feeds, log, shortlog and history views, '-C' for commitdiff view, '--remove-empty' for history view for a file, perhaps even '-c' or '--cc' for commitdiff for merges instead of abusing 'hp' argument for that. But that doesn't mean that this patch should be not applied... it doesn't mean it should be applied neither ;-)
What about this one? gitweb/gitweb.perl | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index dc609f4..f3530ba 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl@@ -383,6 +383,20 @@ if (defined $hash_base) { } } +my %options = ( + "--no-merges" => [('rss', 'atom', 'log', 'shortlog', 'history')], +); + +our $option = $cgi->param('option'); +if (defined $option) { + if (not grep(/^$option$/, keys %options)) { + die_error(undef, "Invalid option parameter"); + } + if (not grep(/^$action$/, @{$options{$option}})) { + die_error(undef, "Invalid option parameter for this action"); + } +} + our $hash_parent_base = $cgi->param('hpb'); if (defined $hash_parent_base) { if (!validate_refname($hash_parent_base)) {
@@ -534,6 +548,7 @@ sub href(%) { action => "a", file_name => "f", file_parent => "fp", + option => "option", hash => "h", hash_parent => "hp", hash_base => "hb",
@@ -1770,6 +1785,7 @@ sub parse_commits { ($arg ? ($arg) : ()), ("--max-count=" . $maxcount), ("--skip=" . $skip), + ((defined $option) ? ($option) : ()), $commit_id, "--", ($filename ? ($filename) : ())
--
1.5.3.rc0.39.g46f7-dirty