gitk: Add visiblerefs option, which lists always-shown branches

When many branches contain a commit, the branches used to be shown in the form "A, B and many more", where A, B can be master of current HEAD. But there are more which might be interesting to always know about. For example, "origin/master". The new option, visiblerefs, is stored in ~/.gitk. It contains a list of references which are always shown before "and many more" if they contain the commit. By default it is `{"master"}', which is compatible with previous behavior. Signed-off-by: Max Kirillov <max@max630.net> Signed-off-by: Paul Mackerras <paulus@samba.org>

Max Kirillov committed Jun 24, 2014 at 08:19 UTC bde4a0f9f3035d482a80c32b4a485333b9ed4875
1 file changed +6 -4
gitk
+6 -4
@@ -2787,7 +2787,7 @@ proc savestuff {w} {
2787 global mainheadcirclecolor workingfilescirclecolor indexcirclecolor
2788 global linkfgcolor circleoutlinecolor
2789 global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
2790 - global hideremotes want_ttk maxrefs
2790 + global hideremotes want_ttk maxrefs visiblerefs
2791 global config_file config_file_tmp
2792
2793 if {$stuffsaved} return
@@ -2813,6 +2813,7 @@ proc savestuff {w} {
2813 puts $f [list set autosellen $autosellen]
2814 puts $f [list set showneartags $showneartags]
2815 puts $f [list set maxrefs $maxrefs]
2816 + puts $f [list set visiblerefs $visiblerefs]
2817 puts $f [list set hideremotes $hideremotes]
2818 puts $f [list set showlocalchanges $showlocalchanges]
2819 puts $f [list set datetimeformat $datetimeformat]
@@ -7035,7 +7036,7 @@ proc viewnextline {dir} {
7036 # add a list of tag or branch names at position pos
7037 # returns the number of names inserted
7038 proc appendrefs {pos ids var} {
7038 - global ctext linknum curview $var maxrefs mainheadid
7039 + global ctext linknum curview $var maxrefs visiblerefs mainheadid
7040
7041 if {[catch {$ctext index $pos}]} {
7042 return 0
@@ -7056,14 +7057,14 @@ proc appendrefs {pos ids var} {
7057 if {[llength $tags] > $maxrefs} {
7058 # If we are displaying heads, and there are too many,
7059 # see if there are some important heads to display.
7059 - # Currently this means "master" and the current head.
7060 + # Currently that are the current head and heads listed in $visiblerefs option
7061 set itags {}
7062 if {$var eq "idheads"} {
7063 set utags {}
7064 foreach ti $tags {
7065 set hname [lindex $ti 0]
7066 set id [lindex $ti 1]
7066 - if {($hname eq "master" || $id eq $mainheadid) &&
7067 + if {([lsearch -exact $visiblerefs $hname] != -1 || $id eq $mainheadid) &&
7068 [llength $itags] < $maxrefs} {
7069 lappend itags $ti
7070 } else {
@@ -12045,6 +12046,7 @@ set wrapcomment "none"
12046 set showneartags 1
12047 set hideremotes 0
12048 set maxrefs 20
12049 +set visiblerefs {"master"}
12050 set maxlinelen 200
12051 set showlocalchanges 1
12052 set limitdiffs 1