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

[PATCH 6/7] gitweb: Sort query string parameters in href() function

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 17, 2006, 09:21 UTC
Message-ID
<1155806489764-git-send-email-jnareb@gmail.com>
In-Reply-To
<11558064883957-git-send-email-jnareb@gmail.com>

Introduction of a href() function to generate an URL for the CGI, while making it easier to change the encoding of actions into URLs, changed also the ordering of parameters in query string, and in URL.

This patch tries to bring back old ordering of query string parameters. Probably it is not worth the cost; this is an RFC.

Signed-off-by: Jakub Narebski <jnareb@gmail.com>
---
 gitweb/gitweb.perl |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index b3f38bf..d132aab 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -197,8 +197,29 @@ sub href(%) {
 		hash_base => "hb",
 		page => "pg",
 		searchtext => "s",
+		order => "o",
 	);
 
+	my %ordering = (
+		project => 0,
+		action => 1,
+		order => 2,
+		hash => 10,
+		hash_parent => 11,
+		hash_base => 12,
+		page => 20,
+		file_name => 21,
+		searchtext => 22,
+	);
+
+	sub byordering ($$) {
+		if (exists $ordering{$_[0]} && exists $ordering{$_[1]}) {
+			return $ordering{$_[0]} <=> $ordering{$_[1]};
+		} else {
+			return $_[0] cmp $_[1];
+		}
+	}
+
 	my %params = @_;
 	$params{"project"} ||= $project;
 
@@ -210,7 +231,7 @@ sub href(%) {
 			} else {
 				"$_=$params{$_}";
 			}
-		} keys %params ) );
+		} sort byordering keys %params ) );
 
 	return $href;
 }
-- 
1.4.1.1
Previous: Junio C HamanoNext: Jakub Narebski
Message 11 of 12 in “A few gitweb cleanups and improvements”
  1. 0/7 A few gitweb cleanups and improvementsJakub Narebski, Aug 17, 2006
  2. 1/7 gitweb: Add support for per project git URLsJakub Narebski, Aug 17, 2006
  3. David RientjesAug 17, 2006
  4. 2/7 gitweb: Refactor printing commit messageJakub Narebski, Aug 17, 2006
  5. 3/7 gitweb: Fix typo in separation of git_difftree_bodyJakub Narebski, Aug 17, 2006
  6. 4/7 gitweb: Expand href() function to use key as param name for no mappingJakub Narebski, Aug 17, 2006
  7. Junio C HamanoAug 17, 2006
  8. Jakub NarebskiAug 17, 2006
  9. 5/7 gitweb: Added parse_difftree_raw_line function for later useJakub Narebski, Aug 17, 2006
  10. Junio C HamanoAug 17, 2006
  11. 6/7 gitweb: Sort query string parameters in href() functionJakub Narebski, Aug 17, 2006
  12. 7/7 gitweb: Uniquify version info output, add meta generator in page headerJakub Narebski, Aug 17, 2006

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.