Thread (11 messages) flat view 11 messages, 3 authors, 2016-06-15
DORMANTno replies

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

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:42:37
Subsystem: the rest · Maintainer: Linus Torvalds

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 <redacted>
---
 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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help