Skip to content

Commit 8353392

Browse files
committed
gitk: Add user preference to hide custom references
External tools such as Jujutsu may add many references that are of no interest to the user. This preference hides them. The non-custom refs are those that pass git's default decoration filter (see set_default_decoration_filter), bisect/*, and rewritten/*. The preference is off by default, maintaining current behavior. Signed-off-by: Ori Avtalion <[email protected]>
1 parent 9f27318 commit 8353392

File tree

1 file changed

+41
-9
lines changed

1 file changed

+41
-9
lines changed

gitk

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,7 @@ proc readrefs {} {
19031903
global otherrefids idotherrefs mainhead mainheadid
19041904
global selecthead selectheadid
19051905
global hideremotes
1906+
global hidecustomrefs
19061907
global tclencoding
19071908
19081909
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
@@ -1939,8 +1940,10 @@ proc readrefs {} {
19391940
set tagids($name) $id
19401941
lappend idtags($id) $name
19411942
} else {
1942-
set otherrefids($name) $id
1943-
lappend idotherrefs($id) $name
1943+
if [filter_ref $name] {
1944+
set otherrefids($name) $id
1945+
lappend idotherrefs($id) $name
1946+
}
19441947
}
19451948
}
19461949
catch {close $refd}
@@ -11696,7 +11699,7 @@ proc prefspage_general {notebook} {
1169611699
global NS maxwidth maxgraphpct showneartags showlocalchanges
1169711700
global tabstop wrapcomment wrapdefault limitdiffs
1169811701
global autocopy autoselect autosellen extdifftool perfile_attrs
11699-
global hideremotes want_ttk have_ttk maxrefs web_browser
11702+
global hideremotes hidecustomrefs want_ttk have_ttk maxrefs web_browser
1170011703
1170111704
set page [create_prefs_page $notebook.general]
1170211705
@@ -11716,6 +11719,9 @@ proc prefspage_general {notebook} {
1171611719
${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
1171711720
-variable hideremotes
1171811721
grid x $page.hideremotes -sticky w
11722+
${NS}::checkbutton $page.hidecustomrefs -text [mc "Hide custom refs"] \
11723+
-variable hidecustomrefs
11724+
grid x $page.hidecustomrefs -sticky w
1171911725
1172011726
${NS}::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
1172111727
-variable autocopy
@@ -11863,7 +11869,7 @@ proc doprefs {} {
1186311869
global oldprefs prefstop showneartags showlocalchanges
1186411870
global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
1186511871
global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
11866-
global hideremotes want_ttk have_ttk wrapcomment wrapdefault
11872+
global hideremotes hidecustomrefs want_ttk have_ttk wrapcomment wrapdefault
1186711873
1186811874
set top .gitkprefs
1186911875
set prefstop $top
@@ -11872,7 +11878,8 @@ proc doprefs {} {
1187211878
return
1187311879
}
1187411880
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
11875-
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
11881+
limitdiffs tabstop perfile_attrs hideremotes hidecustomrefs \
11882+
want_ttk wrapcomment wrapdefault} {
1187611883
set oldprefs($v) [set $v]
1187711884
}
1187811885
ttk_toplevel $top
@@ -11998,7 +12005,8 @@ proc prefscan {} {
1199812005
global oldprefs prefstop
1199912006
1200012007
foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
12001-
limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
12008+
limitdiffs tabstop perfile_attrs hideremotes hidecustomrefs \
12009+
want_ttk wrapcomment wrapdefault} {
1200212010
global $v
1200312011
set $v $oldprefs($v)
1200412012
}
@@ -12012,7 +12020,7 @@ proc prefsok {} {
1201212020
global oldprefs prefstop showneartags showlocalchanges
1201312021
global fontpref mainfont textfont uifont
1201412022
global limitdiffs treediffs perfile_attrs
12015-
global hideremotes wrapcomment wrapdefault
12023+
global hideremotes hidecustomrefs wrapcomment wrapdefault
1201612024
global ctext
1201712025
1201812026
catch {destroy $prefstop}
@@ -12059,7 +12067,7 @@ proc prefsok {} {
1205912067
$limitdiffs != $oldprefs(limitdiffs)} {
1206012068
reselectline
1206112069
}
12062-
if {$hideremotes != $oldprefs(hideremotes)} {
12070+
if {$hideremotes != $oldprefs(hideremotes) || $hidecustomrefs != $oldprefs(hidecustomrefs)} {
1206312071
rereadrefs
1206412072
}
1206512073
if {$wrapcomment != $oldprefs(wrapcomment)} {
@@ -12436,6 +12444,29 @@ proc get_path_encoding {path} {
1243612444
return $tcl_enc
1243712445
}
1243812446
12447+
set default_refs {
12448+
"stash"
12449+
"replace/*"
12450+
"bisect/*"
12451+
"rewritten/*"
12452+
}
12453+
12454+
proc filter_ref {ref} {
12455+
global hidecustomrefs
12456+
global default_refs
12457+
12458+
if {$hidecustomrefs} {
12459+
foreach pat $default_refs {
12460+
if {[string match $pat $ref]} {
12461+
return 1
12462+
}
12463+
}
12464+
return 0
12465+
}
12466+
12467+
return 1
12468+
}
12469+
1243912470
## For msgcat loading, first locate the installation location.
1244012471
if { [info exists ::env(GITK_MSGSDIR)] } {
1244112472
## Msgsdir was manually set in the environment.
@@ -12539,6 +12570,7 @@ set wrapcomment "none"
1253912570
set wrapdefault "none"
1254012571
set showneartags 1
1254112572
set hideremotes 0
12573+
set hidecustomrefs 0
1254212574
set maxrefs 20
1254312575
set visiblerefs {"master"}
1254412576
set maxlinelen 200
@@ -12645,7 +12677,7 @@ set config_variables {
1264512677
mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
1264612678
cmitmode wrapcomment wrapdefault autocopy autoselect autosellen
1264712679
showneartags maxrefs visiblerefs
12648-
hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
12680+
hideremotes hidecustomrefs showlocalchanges datetimeformat limitdiffs uicolor want_ttk
1264912681
bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
1265012682
markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor
1265112683
extdifftool perfile_attrs headbgcolor headfgcolor headoutlinecolor

0 commit comments

Comments
 (0)