]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: sort by ref type on the 'tags and heads' view
authorMichael Rappazzo <rappazzo@gmail.com>
Mon, 1 Jun 2015 15:05:25 +0000 (11:05 -0400)
committerJohannes Sixt <j6t@kdbg.org>
Sun, 20 Jul 2025 08:09:34 +0000 (10:09 +0200)
In the 'tags and heads' view, the list of refs was globally sorted,
which caused the local ref list to be split around other ref list types.

This change re-orders the view to be: local refs, remote refs, tags,
and then other refs.

Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
Signed-off-by: Johannes Sixt <j6t@kdbg.org>
gitk

diff --git a/gitk b/gitk
index 0df4eee7333234c09d097c58f750ba2ea475278a..911fa6308961ec2f2e2e73d9cdfb6ffab45802a5 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -10308,39 +10308,56 @@ proc refill_reflist {} {
     global curview
 
     if {![info exists showrefstop] || ![winfo exists $showrefstop]} return
-    set refs {}
+    set localrefs {}
+    set remoterefs {}
+    set tagrefs {}
+    set otherrefs {}
+
     foreach n [array names headids] {
-        if {[string match $reflistfilter $n]} {
+        if {![string match "remotes/*" $n] && [string match $reflistfilter $n]} {
             if {[commitinview $headids($n) $curview]} {
-                if {[string match "remotes/*" $n]} {
-                    lappend refs [list $n R]
-                } else {
-                    lappend refs [list $n H]
-                }
+                lappend localrefs [list $n H]
             } else {
                 interestedin $headids($n) {run refill_reflist}
             }
         }
     }
+    set localrefs [lsort -index 0 $localrefs]
+
+    foreach n [array names headids] {
+        if {[string match "remotes/*" $n] && [string match $reflistfilter $n]} {
+            if {[commitinview $headids($n) $curview]} {
+                lappend remoterefs [list $n R]
+            } else {
+                interestedin $headids($n) {run refill_reflist}
+            }
+        }
+    }
+    set remoterefs [lsort -index 0 $remoterefs]
+
     foreach n [array names tagids] {
         if {[string match $reflistfilter $n]} {
             if {[commitinview $tagids($n) $curview]} {
-                lappend refs [list $n T]
+                lappend tagrefs [list $n T]
             } else {
                 interestedin $tagids($n) {run refill_reflist}
             }
         }
     }
+    set tagrefs [lsort -index 0 $tagrefs]
+
     foreach n [array names otherrefids] {
         if {[string match $reflistfilter $n]} {
             if {[commitinview $otherrefids($n) $curview]} {
-                lappend refs [list $n o]
+                lappend otherrefs [list "$n" o]
             } else {
                 interestedin $otherrefids($n) {run refill_reflist}
             }
         }
     }
-    set refs [lsort -index 0 $refs]
+    set otherrefs [lsort -index 0 $otherrefs]
+    set refs [concat $localrefs $remoterefs $tagrefs $otherrefs]
+
     if {$refs eq $reflist} return
 
     # Update the contents of $showrefstop.list according to the