Skip to content

Commit fe567b3

Browse files
committed
gitk: Add user preference to hide specific references
External tools such as Jujutsu may add many references that are of no interest to the user. This preference allows hiding them. Signed-off-by: Ori Avtalion <[email protected]>
1 parent 9f27318 commit fe567b3

File tree

1 file changed

+38
-9
lines changed

1 file changed

+38
-9
lines changed

gitk

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1939,8 +1939,10 @@ proc readrefs {} {
19391939
set tagids($name) $id
19401940
lappend idtags($id) $name
19411941
} else {
1942-
set otherrefids($name) $id
1943-
lappend idotherrefs($id) $name
1942+
if [filter_ref $name] {
1943+
set otherrefids($name) $id
1944+
lappend idotherrefs($id) $name
1945+
}
19441946
}
19451947
}
19461948
catch {close $refd}
@@ -11696,7 +11698,7 @@ proc prefspage_general {notebook} {
1169611698
global NS maxwidth maxgraphpct showneartags showlocalchanges
1169711699
global tabstop wrapcomment wrapdefault limitdiffs
1169811700
global autocopy autoselect autosellen extdifftool perfile_attrs
11699-
global hideremotes want_ttk have_ttk maxrefs web_browser
11701+
global hideremotes refstohide want_ttk have_ttk maxrefs web_browser
1170011702
1170111703
set page [create_prefs_page $notebook.general]
1170211704
@@ -11717,6 +11719,13 @@ proc prefspage_general {notebook} {
1171711719
-variable hideremotes
1171811720
grid x $page.hideremotes -sticky w
1171911721
11722+
${NS}::entry $page.refstohide -textvariable refstohide
11723+
${NS}::frame $page.refstohidef
11724+
${NS}::label $page.refstohidef.l -text [mc "Refs to hide (space-separated)" ]
11725+
pack $page.refstohidef.l -side left
11726+
pack configure $page.refstohidef.l -padx 10
11727+
grid x $page.refstohidef $page.refstohide -sticky ew
11728+
1172011729
${NS}::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
1172111730
-variable autocopy
1172211731
grid x $page.autocopy -sticky w
@@ -11863,7 +11872,7 @@ proc doprefs {} {
1186311872
global oldprefs prefstop showneartags showlocalchanges
1186411873
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
1186511874
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11866-
global hideremotes want_ttk have_ttk wrapcomment wrapdefault
11875+
global hideremotes refstohide want_ttk have_ttk wrapcomment wrapdefault
1186711876
1186811877
set top .gitkprefs
1186911878
set prefstop $top
@@ -11872,7 +11881,8 @@ proc doprefs {} {
1187211881
return
1187311882
}
1187411883
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11875-
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
11884+
limitdiffs tabstop perfile_attrs hideremotes refstohide \
11885+
want_ttk wrapcomment wrapdefault} {
1187611886
set oldprefs($v) [set $v]
1187711887
}
1187811888
ttk_toplevel $top
@@ -11998,7 +12008,8 @@ proc prefscan {} {
1199812008
global oldprefs prefstop
1199912009
1200012010
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
12001-
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
12011+
limitdiffs tabstop perfile_attrs hideremotes refstohide \
12012+
want_ttk wrapcomment wrapdefault} {
1200212013
global $v
1200312014
set $v $oldprefs($v)
1200412015
}
@@ -12012,7 +12023,7 @@ proc prefsok {} {
1201212023
global oldprefs prefstop showneartags showlocalchanges
1201312024
global fontpref mainfont textfont uifont
1201412025
global limitdiffs treediffs perfile_attrs
12015-
global hideremotes wrapcomment wrapdefault
12026+
global hideremotes refstohide wrapcomment wrapdefault
1201612027
global ctext
1201712028
1201812029
catch {destroy $prefstop}
@@ -12059,7 +12070,7 @@ proc prefsok {} {
1205912070
$limitdiffs != $oldprefs(limitdiffs)} {
1206012071
reselectline
1206112072
}
12062-
if {$hideremotes != $oldprefs(hideremotes)} {
12073+
if {$hideremotes != $oldprefs(hideremotes) || $refstohide != $oldprefs(refstohide)} {
1206312074
rereadrefs
1206412075
}
1206512076
if {$wrapcomment != $oldprefs(wrapcomment)} {
@@ -12436,6 +12447,23 @@ proc get_path_encoding {path} {
1243612447
return $tcl_enc
1243712448
}
1243812449
12450+
proc filter_ref {ref} {
12451+
global refstohide
12452+
12453+
if {$refstohide == ""} {
12454+
return 1
12455+
}
12456+
12457+
foreach pat [split $refstohide " "] {
12458+
if {$pat == {}} continue
12459+
if {[string match $pat $ref]} {
12460+
return 0
12461+
}
12462+
}
12463+
12464+
return 1
12465+
}
12466+
1243912467
## For msgcat loading, first locate the installation location.
1244012468
if { [info exists ::env(GITK_MSGSDIR)] } {
1244112469
## Msgsdir was manually set in the environment.
@@ -12539,6 +12567,7 @@ set wrapcomment "none"
1253912567
set wrapdefault "none"
1254012568
set showneartags 1
1254112569
set hideremotes 0
12570+
set refstohide ""
1254212571
set maxrefs 20
1254312572
set visiblerefs {"master"}
1254412573
set maxlinelen 200
@@ -12645,7 +12674,7 @@ set config_variables {
1264512674
mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
1264612675
cmitmode wrapcomment wrapdefault autocopy autoselect autosellen
1264712676
showneartags maxrefs visiblerefs
12648-
hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
12677+
hideremotes refstohide showlocalchanges datetimeformat limitdiffs uicolor want_ttk
1264912678
bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
1265012679
markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor
1265112680
extdifftool perfile_attrs headbgcolor headfgcolor headoutlinecolor

0 commit comments

Comments
 (0)