From: Michael Rappazzo <rappazzo@gmail.com>
To: paulus@samba.org
Cc: git@vger.kernel.org, Michael Rappazzo <rappazzo@gmail.com>
Subject: [PATCH v3 1/2] gitk: alter the ordering for the "Tags and heads" view
Date: Sun, 27 Mar 2016 11:06:07 -0400 [thread overview]
Message-ID: <1459091168-46908-2-git-send-email-rappazzo@gmail.com> (raw)
In-Reply-To: <1459091168-46908-1-git-send-email-rappazzo@gmail.com>
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
next prev parent reply other threads:[~2016-03-27 15:06 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2016-12-11 23:25 ` [PATCH v3 1/2] gitk: alter the ordering " 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1459091168-46908-2-git-send-email-rappazzo@gmail.com \
--to=rappazzo@gmail.com \
--cc=git@vger.kernel.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).