{"thread":{"id":"41839","subject":"[PATCH v3 1/2] gitk: alter the ordering for the \"Tags and heads\" view","startedAt":"2016-03-27T15:06:06Z","lastAt":"2016-12-11T23:43:10Z","messageCount":5,"participants":["Michael Rappazzo","Mike Rappazzo","Paul Mackerras"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"281935","messageId":"1459091168-46908-1-git-send-email-rappazzo@gmail.com","threadId":"41839","inReplyTo":null,"subject":"[PATCH v3 0/2] gitk: changes for the \"Tags and heads\" view","fromName":"Michael Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2016-03-27T15:06:06Z","receivedAt":"2016-03-27T15:06:06Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"Changes since v2[1]:\n - Instead of getting the remote info for each local branch individually,\n   grab it all at once and store the result\n - Instead of a command line option to enable the new sorting option,\n   enable it with a preference which is stored in the config.\n\nv1 can be found here[2].\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/289244\n[2] http://thread.gmane.org/gmane.comp.version-control.git/288544\n\nMichael Rappazzo (2):\n  gitk: alter the ordering for the \"Tags and heads\" view\n  gitk: add an option to enable sorting the \"Tags and heads\" view by ref\n    type\n\n gitk | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------\n 1 file changed, 66 insertions(+), 13 deletions(-)\n\n-- \n2.7.4\n"},{"id":"281934","messageId":"1459091168-46908-2-git-send-email-rappazzo@gmail.com","threadId":"41839","inReplyTo":"1459091168-46908-1-git-send-email-rappazzo@gmail.com","subject":"[PATCH v3 1/2] gitk: alter the ordering for the \"Tags and heads\" view","fromName":"Michael Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2016-03-27T15:06:07Z","receivedAt":"2016-03-27T15:06:07Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"In the \"Tags and heads\" view, the list of refs is globally sorted.\nBecause of this, the list of local refs (heads) can be interrupted by the\nlist of remote refs.  This change re-orders the view to be: local refs,\nremote refs tracked by local refs, remote refs, tags, and then other refs.\n\nSigned-off-by: Michael Rappazzo <rappazzo@gmail.com>\n---\n gitk | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++---------\n 1 file changed, 51 insertions(+), 9 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 805a1c7..3686370 100755\n--- a/gitk\n+++ b/gitk\n@@ -1772,12 +1772,12 @@ proc longid {prefix} {\n }\n \n proc readrefs {} {\n-    global tagids idtags headids idheads tagobjid\n+    global tagids idtags headids idheads tagobjid localrefs_tracking_remotes\n     global otherrefids idotherrefs mainhead mainheadid\n     global selecthead selectheadid\n     global hideremotes\n \n-    foreach v {tagids idtags headids idheads otherrefids idotherrefs} {\n+    foreach v {tagids idtags headids idheads otherrefids idotherrefs localrefs_tracking_remotes} {\n \tunset -nocomplain $v\n     }\n     set refd [open [list | git show-ref -d] r]\n@@ -1828,6 +1828,21 @@ proc readrefs {} {\n \t    set selectheadid [exec git rev-parse --verify $selecthead]\n \t}\n     }\n+    #load the local_branch->upstream mapping\n+    # the result of the for-each-ref command produces the local_branch NUL upstream\n+    set locals_tracking [open [list | git for-each-ref {--format=%(refname:short)%00%(upstream)} refs/heads/] r]\n+    while {[gets $locals_tracking local_tracking] >= 0} {\n+\tset line [split $local_tracking \\0]\n+\tif {[lindex $line 1] ne {}} {\n+\t    set upstream_ref [string map {\"refs/\" \"\"} [lindex $line 1]];\n+\t    set upstream_exists {}\n+\t    catch {set upstream_exists [exec git rev-parse --verify $upstream_ref]}\n+\t    if {$upstream_exists ne \"\"} {\n+\t\tset localrefs_tracking_remotes([lindex $line 0]) $upstream_ref\n+\t    }\n+\t}\n+    }\n+    catch {close $locals_tracking}\n }\n \n # skip over fake commits\n@@ -9929,39 +9944,66 @@ proc reflistfilter_change {n1 n2 op} {\n }\n \n proc refill_reflist {} {\n-    global reflist reflistfilter showrefstop headids tagids otherrefids\n+    global reflist reflistfilter showrefstop headids tagids otherrefids localrefs_tracking_remotes\n     global curview\n \n     if {![info exists showrefstop] || ![winfo exists $showrefstop]} return\n-    set refs {}\n+    set localrefs {}\n+    set remoterefs {}\n+    set locally_tracked_remote_refs {}\n+    set tagrefs {}\n+    set otherrefs {}\n+\n     foreach n [array names headids] {\n-\tif {[string match $reflistfilter $n]} {\n+\tif {![string match \"remotes/*\" $n] && [string match $reflistfilter $n]} {\n \t    if {[commitinview $headids($n) $curview]} {\n-\t\tlappend refs [list $n H]\n+\t\tlappend localrefs [list $n H]\n+\t\tif {[info exists localrefs_tracking_remotes($n)]} {\n+\t\t    lappend locally_tracked_remote_refs [list $localrefs_tracking_remotes($n) H]\n+\t\t}\n \t    } else {\n \t\tinterestedin $headids($n) {run refill_reflist}\n \t    }\n \t}\n     }\n+    set locally_tracked_remote_refs [lsort -index 0 $locally_tracked_remote_refs]\n+    set localrefs [lsort -index 0 $localrefs]\n+\n+    foreach n [array names headids] {\n+\tif {[string match \"remotes/*\" $n] && [string match $reflistfilter $n]} {\n+\t    if {[commitinview $headids($n) $curview]} {\n+\t\tif {[lsearch -exact $locally_tracked_remote_refs [list $n H]] < 0} {\n+\t\t    lappend remoterefs [list $n H]\n+\t\t}\n+\t    } else {\n+\t\tinterestedin $headids($n) {run refill_reflist}\n+\t    }\n+\t}\n+    }\n+    set remoterefs [lsort -index 0 $remoterefs]\n+\n     foreach n [array names tagids] {\n \tif {[string match $reflistfilter $n]} {\n \t    if {[commitinview $tagids($n) $curview]} {\n-\t\tlappend refs [list $n T]\n+\t\tlappend tagrefs [list $n T]\n \t    } else {\n \t\tinterestedin $tagids($n) {run refill_reflist}\n \t    }\n \t}\n     }\n+    set tagrefs [lsort -index 0 $tagrefs]\n+\n     foreach n [array names otherrefids] {\n \tif {[string match $reflistfilter $n]} {\n \t    if {[commitinview $otherrefids($n) $curview]} {\n-\t\tlappend refs [list $n o]\n+\t\tlappend otherrefs [list \"$n\" o]\n \t    } else {\n \t\tinterestedin $otherrefids($n) {run refill_reflist}\n \t    }\n \t}\n     }\n-    set refs [lsort -index 0 $refs]\n+    set otherrefs [lsort -index 0 $otherrefs]\n+    lappend refs {*}$localrefs {*}$locally_tracked_remote_refs {*}$remoterefs {*}$tagrefs {*}$otherrefs\n     if {$refs eq $reflist} return\n \n     # Update the contents of $showrefstop.list according to the\n-- \n2.7.4\n"},{"id":"281936","messageId":"1459091168-46908-3-git-send-email-rappazzo@gmail.com","threadId":"41839","inReplyTo":"1459091168-46908-1-git-send-email-rappazzo@gmail.com","subject":"[PATCH v3 2/2] gitk: add an option to enable sorting the \"Tags and heads\" view by ref type","fromName":"Michael Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2016-03-27T15:06:08Z","receivedAt":"2016-03-27T15:06:08Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>\n---\n gitk | 21 ++++++++++++++++-----\n 1 file changed, 16 insertions(+), 5 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 3686370..29ef36c 100755\n--- a/gitk\n+++ b/gitk\n@@ -9944,7 +9944,7 @@ proc reflistfilter_change {n1 n2 op} {\n }\n \n proc refill_reflist {} {\n-    global reflist reflistfilter showrefstop headids tagids otherrefids localrefs_tracking_remotes\n+    global reflist reflistfilter showrefstop headids tagids otherrefids localrefs_tracking_remotes sortrefsbytype\n     global curview\n \n     if {![info exists showrefstop] || ![winfo exists $showrefstop]} return\n@@ -10004,6 +10004,10 @@ proc refill_reflist {} {\n     }\n     set otherrefs [lsort -index 0 $otherrefs]\n     lappend refs {*}$localrefs {*}$locally_tracked_remote_refs {*}$remoterefs {*}$tagrefs {*}$otherrefs\n+    if {$sortrefsbytype ne 1} {\n+       set refs [lsort -index 0 $refs]\n+    }\n+\n     if {$refs eq $reflist} return\n \n     # Update the contents of $showrefstop.list according to the\n@@ -11416,7 +11420,7 @@ proc create_prefs_page {w} {\n proc prefspage_general {notebook} {\n     global NS maxwidth maxgraphpct showneartags showlocalchanges\n     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs\n-    global hideremotes want_ttk have_ttk maxrefs\n+    global hideremotes want_ttk have_ttk maxrefs sortrefsbytype\n \n     set page [create_prefs_page $notebook.general]\n \n@@ -11440,6 +11444,9 @@ proc prefspage_general {notebook} {\n     ${NS}::checkbutton $page.hideremotes -text [mc \"Hide remote refs\"] \\\n \t-variable hideremotes\n     grid x $page.hideremotes -sticky w\n+    ${NS}::checkbutton $page.sortrefsbytype -text [mc \"Sort refs by type\"] \\\n+\t-variable sortrefsbytype\n+    grid x $page.sortrefsbytype -sticky w\n \n     ${NS}::label $page.ddisp -text [mc \"Diff display options\"]\n     grid $page.ddisp - -sticky w -pady 10\n@@ -11544,7 +11551,7 @@ proc doprefs {} {\n     global oldprefs prefstop showneartags showlocalchanges\n     global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor\n     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs\n-    global hideremotes want_ttk have_ttk\n+    global hideremotes want_ttk have_ttk sortrefsbytype\n \n     set top .gitkprefs\n     set prefstop $top\n@@ -11553,7 +11560,8 @@ proc doprefs {} {\n \treturn\n     }\n     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \\\n-\t\t   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {\n+\t\t   limitdiffs tabstop perfile_attrs hideremotes want_ttk \\\n+\t\t   sortrefsbytype} {\n \tset oldprefs($v) [set $v]\n     }\n     ttk_toplevel $top\n@@ -11679,7 +11687,8 @@ proc prefscan {} {\n     global oldprefs prefstop\n \n     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \\\n-\t\t   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {\n+\t\t   limitdiffs tabstop perfile_attrs hideremotes want_ttk \\\n+\t\t   sortrefsbytype} {\n \tglobal $v\n \tset $v $oldprefs($v)\n     }\n@@ -12215,6 +12224,7 @@ set showneartags 1\n set hideremotes 0\n set maxrefs 20\n set visiblerefs {\"master\"}\n+set sortrefsbytype 0\n set maxlinelen 200\n set showlocalchanges 1\n set limitdiffs 1\n@@ -12318,6 +12328,7 @@ set config_variables {\n     filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor\n     linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor\n     indexcirclecolor circlecolors linkfgcolor circleoutlinecolor\n+    sortrefsbytype\n }\n foreach var $config_variables {\n     config_init_trace $var\n-- \n2.7.4\n"},{"id":"284795","messageId":"CANoM8SXZjcDxrNoosk2agzq=nq_MnenoRtDMbY414o50OtzWig@mail.gmail.com","threadId":"41839","inReplyTo":"1459091168-46908-1-git-send-email-rappazzo@gmail.com","subject":"Re: [PATCH v3 0/2] gitk: changes for the \"Tags and heads\" view","fromName":"Mike Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2016-04-28T12:42:11Z","receivedAt":"2016-04-28T12:42:11Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"On Sun, Mar 27, 2016 at 11:06 AM, Michael Rappazzo <rappazzo@gmail.com> wrote:\n> Changes since v2[1]:\n>  - Instead of getting the remote info for each local branch individually,\n>    grab it all at once and store the result\n>  - Instead of a command line option to enable the new sorting option,\n>    enable it with a preference which is stored in the config.\n>\n> v1 can be found here[2].\n>\n> [1] http://thread.gmane.org/gmane.comp.version-control.git/289244\n> [2] http://thread.gmane.org/gmane.comp.version-control.git/288544\n>\n> Michael Rappazzo (2):\n>   gitk: alter the ordering for the \"Tags and heads\" view\n>   gitk: add an option to enable sorting the \"Tags and heads\" view by ref\n>     type\n>\n>  gitk | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------\n>  1 file changed, 66 insertions(+), 13 deletions(-)\n>\n> --\n> 2.7.4\n>\n\nI am still looking for comments on this patch.\n\nAlso, is there a 'pu' repo for gitk?  Currently, I am only tracking\ngit://ozlabs.org/~paulus/gitk\n"},{"id":"307477","messageId":"20161211232502.GA18316@fergus.ozlabs.ibm.com","threadId":"41839","inReplyTo":"1459091168-46908-2-git-send-email-rappazzo@gmail.com","subject":"Re: [PATCH v3 1/2] gitk: alter the ordering for the \"Tags and heads\" view","fromName":"Paul Mackerras","fromEmail":"paulus@ozlabs.org","sentAt":"2016-12-11T23:25:02Z","receivedAt":"2016-12-11T23:43:10Z","isPatch":true,"sender":{"key":"paulus@ozlabs.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Sun, Mar 27, 2016 at 11:06:07AM -0400, Michael Rappazzo wrote:\n> In the \"Tags and heads\" view, the list of refs is globally sorted.\n> Because of this, the list of local refs (heads) can be interrupted by the\n> list of remote refs.  This change re-orders the view to be: local refs,\n> remote refs tracked by local refs, remote refs, tags, and then other refs.\n> \n> Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>\n\nThis all looks OK except for the fact that the loop immediately below\nthe code you've modified (the loop that adds or deletes lines from the\nactual displayed list) relies on the entries being in sorted order.\nWith your patch the entries are no longer strictly in sorted order, so\nthat display update loop will have to become a bit smarter too.  As it\nis, I think that there will be cases where we will delete a lot of\nlines and then re-add them.  If the user had scrolled the list to a\nparticular point that was within these deleted lines, the display will\nscroll away from that point, which will be annoying.\n\nPaul.\n"}]}