* [PATCH v3 0/2] gitk: changes for the "Tags and heads" view
@ 2016-03-27 15:06 Michael Rappazzo
2016-03-27 15:06 ` [PATCH v3 1/2] gitk: alter the ordering " Michael Rappazzo
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Michael Rappazzo @ 2016-03-27 15:06 UTC (permalink / raw)
To: paulus; +Cc: git, Michael Rappazzo
Changes since v2[1]:
- Instead of getting the remote info for each local branch individually,
grab it all at once and store the result
- Instead of a command line option to enable the new sorting option,
enable it with a preference which is stored in the config.
v1 can be found here[2].
[1] http://thread.gmane.org/gmane.comp.version-control.git/289244
[2] http://thread.gmane.org/gmane.comp.version-control.git/288544
Michael Rappazzo (2):
gitk: alter the ordering for the "Tags and heads" view
gitk: add an option to enable sorting the "Tags and heads" view by ref
type
gitk | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
1 file changed, 66 insertions(+), 13 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v3 1/2] gitk: alter the ordering for the "Tags and heads" view
2016-03-27 15:06 [PATCH v3 0/2] gitk: changes for the "Tags and heads" view Michael Rappazzo
@ 2016-03-27 15:06 ` Michael Rappazzo
2016-12-11 23:25 ` Paul Mackerras
2016-03-27 15:06 ` [PATCH v3 2/2] gitk: add an option to enable sorting the "Tags and heads" view by ref type Michael Rappazzo
2016-04-28 12:42 ` [PATCH v3 0/2] gitk: changes for the "Tags and heads" view Mike Rappazzo
2 siblings, 1 reply; 5+ messages in thread
From: Michael Rappazzo @ 2016-03-27 15:06 UTC (permalink / raw)
To: paulus; +Cc: git, Michael Rappazzo
In the "Tags and heads" view, the list of refs is globally sorted.
Because of this, the list of local refs (heads) can be interrupted by the
list of remote refs. This change re-orders the view to be: local refs,
remote refs tracked by local refs, remote refs, tags, and then other refs.
Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
---
gitk | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 51 insertions(+), 9 deletions(-)
diff --git a/gitk b/gitk
index 805a1c7..3686370 100755
--- a/gitk
+++ b/gitk
@@ -1772,12 +1772,12 @@ proc longid {prefix} {
}
proc readrefs {} {
- global tagids idtags headids idheads tagobjid
+ global tagids idtags headids idheads tagobjid localrefs_tracking_remotes
global otherrefids idotherrefs mainhead mainheadid
global selecthead selectheadid
global hideremotes
- foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
+ foreach v {tagids idtags headids idheads otherrefids idotherrefs localrefs_tracking_remotes} {
unset -nocomplain $v
}
set refd [open [list | git show-ref -d] r]
@@ -1828,6 +1828,21 @@ proc readrefs {} {
set selectheadid [exec git rev-parse --verify $selecthead]
}
}
+ #load the local_branch->upstream mapping
+ # the result of the for-each-ref command produces the local_branch NUL upstream
+ set locals_tracking [open [list | git for-each-ref {--format=%(refname:short)%00%(upstream)} refs/heads/] r]
+ while {[gets $locals_tracking local_tracking] >= 0} {
+ set line [split $local_tracking \0]
+ if {[lindex $line 1] ne {}} {
+ set upstream_ref [string map {"refs/" ""} [lindex $line 1]];
+ set upstream_exists {}
+ catch {set upstream_exists [exec git rev-parse --verify $upstream_ref]}
+ if {$upstream_exists ne ""} {
+ set localrefs_tracking_remotes([lindex $line 0]) $upstream_ref
+ }
+ }
+ }
+ catch {close $locals_tracking}
}
# skip over fake commits
@@ -9929,39 +9944,66 @@ proc reflistfilter_change {n1 n2 op} {
}
proc refill_reflist {} {
- global reflist reflistfilter showrefstop headids tagids otherrefids
+ global reflist reflistfilter showrefstop headids tagids otherrefids localrefs_tracking_remotes
global curview
if {![info exists showrefstop] || ![winfo exists $showrefstop]} return
- set refs {}
+ set localrefs {}
+ set remoterefs {}
+ set locally_tracked_remote_refs {}
+ 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]} {
- lappend refs [list $n H]
+ lappend localrefs [list $n H]
+ if {[info exists localrefs_tracking_remotes($n)]} {
+ lappend locally_tracked_remote_refs [list $localrefs_tracking_remotes($n) H]
+ }
} else {
interestedin $headids($n) {run refill_reflist}
}
}
}
+ set locally_tracked_remote_refs [lsort -index 0 $locally_tracked_remote_refs]
+ 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]} {
+ if {[lsearch -exact $locally_tracked_remote_refs [list $n H]] < 0} {
+ lappend remoterefs [list $n H]
+ }
+ } 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]
+ lappend refs {*}$localrefs {*}$locally_tracked_remote_refs {*}$remoterefs {*}$tagrefs {*}$otherrefs
if {$refs eq $reflist} return
# Update the contents of $showrefstop.list according to the
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH v3 2/2] gitk: add an option to enable sorting the "Tags and heads" view by ref type
2016-03-27 15:06 [PATCH v3 0/2] gitk: changes for the "Tags and heads" view Michael Rappazzo
2016-03-27 15:06 ` [PATCH v3 1/2] gitk: alter the ordering " Michael Rappazzo
@ 2016-03-27 15:06 ` Michael Rappazzo
2016-04-28 12:42 ` [PATCH v3 0/2] gitk: changes for the "Tags and heads" view Mike Rappazzo
2 siblings, 0 replies; 5+ messages in thread
From: Michael Rappazzo @ 2016-03-27 15:06 UTC (permalink / raw)
To: paulus; +Cc: git, Michael Rappazzo
Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
---
gitk | 21 ++++++++++++++++-----
1 file changed, 16 insertions(+), 5 deletions(-)
diff --git a/gitk b/gitk
index 3686370..29ef36c 100755
--- a/gitk
+++ b/gitk
@@ -9944,7 +9944,7 @@ proc reflistfilter_change {n1 n2 op} {
}
proc refill_reflist {} {
- global reflist reflistfilter showrefstop headids tagids otherrefids localrefs_tracking_remotes
+ global reflist reflistfilter showrefstop headids tagids otherrefids localrefs_tracking_remotes sortrefsbytype
global curview
if {![info exists showrefstop] || ![winfo exists $showrefstop]} return
@@ -10004,6 +10004,10 @@ proc refill_reflist {} {
}
set otherrefs [lsort -index 0 $otherrefs]
lappend refs {*}$localrefs {*}$locally_tracked_remote_refs {*}$remoterefs {*}$tagrefs {*}$otherrefs
+ if {$sortrefsbytype ne 1} {
+ set refs [lsort -index 0 $refs]
+ }
+
if {$refs eq $reflist} return
# Update the contents of $showrefstop.list according to the
@@ -11416,7 +11420,7 @@ proc create_prefs_page {w} {
proc prefspage_general {notebook} {
global NS maxwidth maxgraphpct showneartags showlocalchanges
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
- global hideremotes want_ttk have_ttk maxrefs
+ global hideremotes want_ttk have_ttk maxrefs sortrefsbytype
set page [create_prefs_page $notebook.general]
@@ -11440,6 +11444,9 @@ proc prefspage_general {notebook} {
${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
-variable hideremotes
grid x $page.hideremotes -sticky w
+ ${NS}::checkbutton $page.sortrefsbytype -text [mc "Sort refs by type"] \
+ -variable sortrefsbytype
+ grid x $page.sortrefsbytype -sticky w
${NS}::label $page.ddisp -text [mc "Diff display options"]
grid $page.ddisp - -sticky w -pady 10
@@ -11544,7 +11551,7 @@ proc doprefs {} {
global oldprefs prefstop showneartags showlocalchanges
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
- global hideremotes want_ttk have_ttk
+ global hideremotes want_ttk have_ttk sortrefsbytype
set top .gitkprefs
set prefstop $top
@@ -11553,7 +11560,8 @@ proc doprefs {} {
return
}
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
- limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
+ limitdiffs tabstop perfile_attrs hideremotes want_ttk \
+ sortrefsbytype} {
set oldprefs($v) [set $v]
}
ttk_toplevel $top
@@ -11679,7 +11687,8 @@ proc prefscan {} {
global oldprefs prefstop
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
- limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
+ limitdiffs tabstop perfile_attrs hideremotes want_ttk \
+ sortrefsbytype} {
global $v
set $v $oldprefs($v)
}
@@ -12215,6 +12224,7 @@ set showneartags 1
set hideremotes 0
set maxrefs 20
set visiblerefs {"master"}
+set sortrefsbytype 0
set maxlinelen 200
set showlocalchanges 1
set limitdiffs 1
@@ -12318,6 +12328,7 @@ set config_variables {
filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
indexcirclecolor circlecolors linkfgcolor circleoutlinecolor
+ sortrefsbytype
}
foreach var $config_variables {
config_init_trace $var
--
2.7.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v3 0/2] gitk: changes for the "Tags and heads" view
2016-03-27 15:06 [PATCH v3 0/2] gitk: changes for the "Tags and heads" view Michael Rappazzo
2016-03-27 15:06 ` [PATCH v3 1/2] gitk: alter the ordering " Michael Rappazzo
2016-03-27 15:06 ` [PATCH v3 2/2] gitk: add an option to enable sorting the "Tags and heads" view by ref type Michael Rappazzo
@ 2016-04-28 12:42 ` Mike Rappazzo
2 siblings, 0 replies; 5+ messages in thread
From: Mike Rappazzo @ 2016-04-28 12:42 UTC (permalink / raw)
To: paulus; +Cc: Git List, Michael Rappazzo
On Sun, Mar 27, 2016 at 11:06 AM, Michael Rappazzo <rappazzo@gmail.com> wrote:
> Changes since v2[1]:
> - Instead of getting the remote info for each local branch individually,
> grab it all at once and store the result
> - Instead of a command line option to enable the new sorting option,
> enable it with a preference which is stored in the config.
>
> v1 can be found here[2].
>
> [1] http://thread.gmane.org/gmane.comp.version-control.git/289244
> [2] http://thread.gmane.org/gmane.comp.version-control.git/288544
>
> Michael Rappazzo (2):
> gitk: alter the ordering for the "Tags and heads" view
> gitk: add an option to enable sorting the "Tags and heads" view by ref
> type
>
> gitk | 79 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------
> 1 file changed, 66 insertions(+), 13 deletions(-)
>
> --
> 2.7.4
>
I am still looking for comments on this patch.
Also, is there a 'pu' repo for gitk? Currently, I am only tracking
git://ozlabs.org/~paulus/gitk
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v3 1/2] gitk: alter the ordering for the "Tags and heads" view
2016-03-27 15:06 ` [PATCH v3 1/2] gitk: alter the ordering " Michael Rappazzo
@ 2016-12-11 23:25 ` Paul Mackerras
0 siblings, 0 replies; 5+ messages in thread
From: Paul Mackerras @ 2016-12-11 23:25 UTC (permalink / raw)
To: Michael Rappazzo; +Cc: git
On Sun, Mar 27, 2016 at 11:06:07AM -0400, Michael Rappazzo wrote:
> In the "Tags and heads" view, the list of refs is globally sorted.
> Because of this, the list of local refs (heads) can be interrupted by the
> list of remote refs. This change re-orders the view to be: local refs,
> remote refs tracked by local refs, remote refs, tags, and then other refs.
>
> Signed-off-by: Michael Rappazzo <rappazzo@gmail.com>
This all looks OK except for the fact that the loop immediately below
the code you've modified (the loop that adds or deletes lines from the
actual displayed list) relies on the entries being in sorted order.
With your patch the entries are no longer strictly in sorted order, so
that display update loop will have to become a bit smarter too. As it
is, I think that there will be cases where we will delete a lot of
lines and then re-add them. If the user had scrolled the list to a
particular point that was within these deleted lines, the display will
scroll away from that point, which will be annoying.
Paul.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-12-11 23:43 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-27 15:06 [PATCH v3 0/2] gitk: changes for the "Tags and heads" view Michael Rappazzo
2016-03-27 15:06 ` [PATCH v3 1/2] gitk: alter the ordering " Michael Rappazzo
2016-12-11 23:25 ` Paul Mackerras
2016-03-27 15:06 ` [PATCH v3 2/2] gitk: add an option to enable sorting the "Tags and heads" view by ref type Michael Rappazzo
2016-04-28 12:42 ` [PATCH v3 0/2] gitk: changes for the "Tags and heads" view Mike Rappazzo
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).