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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]