summaryrefslogtreecommitdiff
path: root/gitweb
diff options
context:
space:
mode:
authorGreg Hurrell <greg@hurrell.net>2021-06-09 19:28:06 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-06-10 00:49:20 (GMT)
commita45e390ad6ad1f26967a40e7771777f70a77d719 (patch)
tree921d33096db6608c89f227dfd0be3d01786bf57f /gitweb
parent48bf2fa8bad054d66bd79c6ba903c89c704201f7 (diff)
downloadgit-a45e390ad6ad1f26967a40e7771777f70a77d719.zip
git-a45e390ad6ad1f26967a40e7771777f70a77d719.tar.gz
git-a45e390ad6ad1f26967a40e7771777f70a77d719.tar.bz2
gitweb: use HEAD as secondary sort key in git_get_heads_list()
The "heads" section on the gitweb summary page shows heads in `-committerdate` order (ie. the most recently-modified ones at the top), tie-breaking equal-dated refs using the implicit `refname` sort fallback. This recency-based ordering appears in multiple places in the UI, such as the project listing, the tags list, and even the shortlog and log views. Given two equal-dated refs, however, sorting the `HEAD` ref before the non-`HEAD` ref provides more useful signal than merely sorting by refname. For example, say we had "master" and "trunk" both pointing at the same commit but "trunk" was `HEAD`, sorting "trunk" first helps communicate its special status as the default branch that you'll check out if you clone the repo. Add `-HEAD` as a secondary sort key to the `git for-each-ref` call in `git_get_heads_list()` to provide the desired behavior. The most recently committed refs will appear first, but `HEAD`-ness will be used as a tie-breaker. Note that `refname` is the implicit fallback sort key, which means that two same-dated non-`HEAD` refs will continue to be sorted in lexicographical order, as they are today. Signed-off-by: Greg Hurrell <greg@hurrell.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'gitweb')
-rwxr-xr-xgitweb/gitweb.perl3
1 files changed, 2 insertions, 1 deletions
diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl
index 0959a78..092e707 100755
--- a/gitweb/gitweb.perl
+++ b/gitweb/gitweb.perl
@@ -3779,7 +3779,8 @@ sub git_get_heads_list {
my @headslist;
open my $fd, '-|', git_cmd(), 'for-each-ref',
- ($limit ? '--count='.($limit+1) : ()), '--sort=-committerdate',
+ ($limit ? '--count='.($limit+1) : ()),
+ '--sort=-HEAD', '--sort=-committerdate',
'--format=%(objectname) %(refname) %(subject)%00%(committer)',
@patterns
or return;