git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gitweb: Sort projects with undefined ages last
@ 2012-12-10  4:34 Matthew Daley
  2012-12-10  6:16 ` Junio C Hamano
  0 siblings, 1 reply; 4+ messages in thread
From: Matthew Daley @ 2012-12-10  4:34 UTC (permalink / raw)
  To: git; +Cc: Matthew Daley

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

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-12-11 18:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-10  4:34 [PATCH] gitweb: Sort projects with undefined ages last Matthew Daley
2012-12-10  6:16 ` Junio C Hamano
2012-12-11 10:56   ` Matthew Daley
2012-12-11 18:08     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).