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

[PATCH 1/2] gitweb: Allow for multivalued parameters passed to href subroutine

From
Jakub Narebski <jnareb@gmail.com>
Date
Jul 31, 2007, 11:19 UTC
Message-ID
<1185880790812-git-send-email-jnareb@gmail.com>

Make it possible to generate URLs with multivalued parameters in the href() subroutine, via passing reference to array of values.

Example:
  href(action=>"log", extra_options=>["--no-merges", "--first-parent"])

This also allows for easy passing back (replaying) current value of, possibly multivalued, extra_options ('opt') parameter, using:

  href(..., extra_options=>\@extra_options)

which would be required when we start using extra_options in gitweb, and would want to preserve its value. For example when creating links to next/previous page of 'log' or 'history' view output, we would want to preserve '--no-merges' and/or '-first-parent' extra options.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
This is the same patch as sent earlier, but with more detailed commit
message.  As the previous version made it into git.git, this is just
for archives.
 gitweb/gitweb.perl |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 8a32899..498b936 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -629,7 +629,13 @@ sub href(%) {
 	for (my $i = 0; $i < @mapping; $i += 2) {
 		my ($name, $symbol) = ($mapping[$i], $mapping[$i+1]);
 		if (defined $params{$name}) {
-			push @result, $symbol . "=" . esc_param($params{$name});
+			if (ref($params{$name}) eq "ARRAY") {
+				foreach my $par (@{$params{$name}}) {
+					push @result, $symbol . "=" . esc_param($par);
+				}
+			} else {
+				push @result, $symbol . "=" . esc_param($params{$name});
+			}
 		}
 	}
 	$href .= "?" . join(';', @result) if scalar @result;
-- 
1.5.2.4
Next: Jakub Narebski
Message 1 of 11 in “gitweb: Allow for multivalued parameters passed to href subroutine”
  1. 1/2 gitweb: Allow for multivalued parameters passed to href subroutineJakub Narebski, Jul 31, 2007
  2. 2/2 gitweb: Add an option to show size of blobs in the tree viewJakub Narebski, Jul 31, 2007
  3. Junio C HamanoJul 31, 2007
  4. Jakub NarebskiAug 1, 2007
  5. Junio C HamanoAug 1, 2007
  6. Jakub NarebskiAug 1, 2007
  7. Junio C HamanoAug 2, 2007
  8. Junio C HamanoAug 2, 2007
  9. Jakub NarebskiAug 2, 2007
  10. Junio C HamanoAug 2, 2007
  11. Jakub NarebskiJul 31, 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.