{"thread":{"id":"39492","subject":"[PATCH] gitk: Alter the ordering for the \"Tags and heads\" view","startedAt":"2015-06-02T11:11:09Z","lastAt":"2015-08-13T00:43:02Z","messageCount":3,"participants":["Michael Rappazzo","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"262702","messageId":"1433243470-93392-1-git-send-email-rappazzo@gmail.com","threadId":"39492","inReplyTo":null,"subject":"[PATCH] gitk: Alter the ordering for the \"Tags and heads\" view","fromName":"Michael Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2015-06-02T11:11:09Z","receivedAt":"2015-06-02T11:11:09Z","isPatch":true,"sender":{"key":"rappazzo@gmail.com","avatar":"https://avatars.githubusercontent.com/u/525287?v=4"},"body":"In a codebase with a large number of remote branches, the \"Tags and heads\"\nview can split the local refs around the name \"remotes\".  I wanted to make \nthis view more useful as a quick view of the refs that are important to me\nat the moment (I would say the branches that I am actively looking at).\n\nTherefore, I have made this change to the ordering of the view.  It should\nshow up in the following order:\n\n    local refs\n    remote refs which are tracked (upstream) by local refs\n    remote refs\n    tags\n    other refs\n\nEach of these lists is independently sorted before being put into the main\nref list.  Also note that the upstream refs are _not_ duplicated in the \nremote refs list.\n\nMichael Rappazzo (1):\n  gitk: Alter the ordering for the \"Tags and heads\" view\n\n gitk-git/gitk | 48 ++++++++++++++++++++++++++++++++++++++++++------\n 1 file changed, 42 insertions(+), 6 deletions(-)\n\n-- \n2.4.2\n"},{"id":"262701","messageId":"1433243470-93392-2-git-send-email-rappazzo@gmail.com","threadId":"39492","inReplyTo":"1433243470-93392-1-git-send-email-rappazzo@gmail.com","subject":"[PATCH] gitk: Alter the ordering for the \"Tags and heads\" view","fromName":"Michael Rappazzo","fromEmail":"rappazzo@gmail.com","sentAt":"2015-06-02T11:11:10Z","receivedAt":"2015-06-02T11:11:10Z","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.\nThe list of local refs (heads) is separated by the remote refs.  This\nchange re-orders the view toi be: local refs, remote refs tracked by\nlocal refs, remote refs, tags, and then other refs\n\nSigned-off-by: Michael Rappazzo <rappazzo@gmail.com>\n---\n gitk-git/gitk | 48 ++++++++++++++++++++++++++++++++++++++++++------\n 1 file changed, 42 insertions(+), 6 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 9a2daf3..431a6a1 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -9879,35 +9879,71 @@ proc refill_reflist {} {\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     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 localrefs [list $n H]\n+\t\tcatch {set remote_name [exec git config --get branch.$n.remote]}\n+\t\tif {$remote_name ne \"\"} {\n+\t\t    catch {set remote_ref [exec git config --get branch.$n.merge]}\n+\t\t    set remote_ref [string map {\"refs/heads/\" \"\"} $remote_ref]\n+\t\t    set locally_tracked_remote_ref \"remotes/$remote_name/$remote_ref\"\n+\t\t    catch {set exists [exec git rev-parse --verify $locally_tracked_remote_ref]}\n+\t\t    if {$exists ne \"\"} {\n+\t\t\tif {[lsearch $locally_tracked_remote_refs [list $locally_tracked_remote_ref H]] < 0} {\n+\t\t\t    lappend locally_tracked_remote_refs [list $locally_tracked_remote_ref H]\n+\t\t\t}\n+\t\t    }\n+\t\t    set exists \"\"\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\tlappend refs [list $n H]\n+\t\tif {[lsearch $locally_tracked_remote_refs [list $n H]] < 0} {\n+\t\t    lappend remoterefs [list $n H]\n+        \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.4.2\n"},{"id":"267965","messageId":"20150813004302.GB6686@fergus.ozlabs.ibm.com","threadId":"39492","inReplyTo":"1433243470-93392-2-git-send-email-rappazzo@gmail.com","subject":"Re: [PATCH] gitk: Alter the ordering for the \"Tags and heads\" view","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2015-08-13T00:43:02Z","receivedAt":"2015-08-13T00:43:02Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Tue, Jun 02, 2015 at 07:11:10AM -0400, Michael Rappazzo wrote:\n> In the \"Tags and heads\" view, the list of refs is globally sorted.\n> The list of local refs (heads) is separated by the remote refs.  This\n> change re-orders the view toi be: local refs, remote refs tracked by\n> local refs, remote refs, tags, and then other refs\n> \n> Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>\n\nSorry it's taken me so long to get around to reviewing this.  I have a\ncouple of comments:\n\n> ---\n>  gitk-git/gitk | 48 ++++++++++++++++++++++++++++++++++++++++++------\n>  1 file changed, 42 insertions(+), 6 deletions(-)\n> \n> diff --git a/gitk-git/gitk b/gitk-git/gitk\n> index 9a2daf3..431a6a1 100755\n> --- a/gitk-git/gitk\n> +++ b/gitk-git/gitk\n> @@ -9879,35 +9879,71 @@ proc refill_reflist {} {\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>      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 localrefs [list $n H]\n> +\t\tcatch {set remote_name [exec git config --get branch.$n.remote]}\n> +\t\tif {$remote_name ne \"\"} {\n\nFirst off, if the git config command fails for any reason and returns\nan error status, the set command won't get done and $remote_name will\neither be undefined or will have whatever value it had before.  If it\nis undefined then the if statement is going to throw an error.  I\ndon't think that is what you meant to happen.  This same problem will\noccur for other variables such as $remote_ref and $exists.\n\nSecondly, I'm not very happy about doing all these external git\ncommands every time we run refill_reflist.  Couldn't we cache which\nremote each local branch is tracking?  We would then throw away and\nreload the cache in rereadrefs.  Most executions of refill_reflist\nwould then not need to do any external git commands at all.\n\nPaul.\n"}]}