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

[PATCH] gitweb: Sort projects with undefined ages last

From
MDMatthew Daley <mattjd@gmail.com>
Date
Dec 10, 2012, 04:34 UTC
Message-ID
<1355114061-4652-1-git-send-email-mattjd@gmail.com>

Sorting gitweb's project list by age ('Last Change') currently shows projects with undefined ages at the head of the list. This results in a less useful result when there are a number of projects that are missing or otherwise faulty and one is trying to see what projects have been updated recently.

Fix by sorting these projects with undefined ages at the bottom of the list when sorting by age.

Signed-off-by: Matthew Daley <mattjd@gmail.com>
---
I realize this might be a bit bikesheddy, but it does improve the listing
in the given use case. For an example of the problem, see ie.
http://git.kernel.org/?o=age or http://repo.or.cz/w?a=project_list;o=age .

I'm also not a Perl native, so any advice on making the patch good Perl is appreciated.

 gitweb/gitweb.perl |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0f207f2..21da1b5 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -5541,7 +5541,9 @@ sub sort_projects_list {
 	if ($oi->{'type'} eq 'str') {
 		@projects = sort {$a->{$oi->{'key'}} cmp $b->{$oi->{'key'}}} @$projlist;
 	} else {
-		@projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}} @$projlist;
+		@projects = sort {$a->{$oi->{'key'}} <=> $b->{$oi->{'key'}}}
+		            grep {defined $_->{$oi->{'key'}}} @$projlist;
+		push @projects, grep {!defined $_->{$oi->{'key'}}} @$projlist;
 	}
 
 	return @projects;
-- 
1.7.10.4
Next: Junio C Hamano
Message 1 of 4 in “gitweb: Sort projects with undefined ages last”
  1. gitweb: Sort projects with undefined ages lastMatthew Daley, Dec 10, 2012
  2. Junio C HamanoDec 10, 2012
  3. Matthew DaleyDec 11, 2012
  4. Junio C HamanoDec 11, 2012

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.