git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] gitweb: new cgi parameter: option

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Jul 11, 2007, 23:00 UTC
Message-ID
<20070711230038.GN19386@genesis.frugalware.org>
In-Reply-To
<f73hhc$uo1$1@sea.gmane.org>

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 <vmiklos@frugalware.org>
---
Na Wed, Jul 11, 2007 at 11:19:41PM +0200, Jakub Narebski <jnareb@gmail.com> pisal(a):
Show 5 quoted lines
> Miklos Vajna wrote:
>
> > +((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 :) )
Show 8 quoted lines
> 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
Previous: Jakub NarebskiNext: Jakub Narebski
Message 4 of 9 in “gitweb: New cgi parameter: filter”
  1. gitweb: New cgi parameter: filterMiklos Vajna, Jul 8, 2007
  2. VMiklosJul 9, 2007
  3. Jakub NarebskiJul 11, 2007
  4. gitweb: new cgi parameter: optionMiklos Vajna, Jul 11, 2007
  5. Jakub NarebskiJul 12, 2007
  6. Johannes SchindelinJul 12, 2007
  7. gitweb: new cgi parameter: optMiklos Vajna, Jul 12, 2007
  8. Junio C HamanoJul 12, 2007
  9. Jakub NarebskiJul 13, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.