gitk: Add user preference to hide custom references #1

open
opened by ilyagr.bsky.social targeting test from pr/16

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).

The preference is off by default, maintaining current behavior.

Signed-off-by: Ori Avtalion ori@avtalion.name

Changed files
+31 -3
+31 -3
gitk
···
set tagids($name) $id
lappend idtags($id) $name
} else {
-
set otherrefids($name) $id
-
lappend idotherrefs($id) $name
+
if [is_other_ref_visible $name] {
+
set otherrefids($name) $id
+
lappend idotherrefs($id) $name
+
}
catch {close $refd}
···
-variable hideremotes
grid x $page.hideremotes -sticky w
+
ttk::entry $page.refstohide -textvariable refstohide
+
ttk::frame $page.refstohidef
+
ttk::label $page.refstohidef.l -text [mc "Refs to hide (space-separated)" ]
+
pack $page.refstohidef.l -side left
+
pack configure $page.refstohidef.l -padx 10
+
grid x $page.refstohidef $page.refstohide -sticky ew
+
ttk::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
-variable autocopy
grid x $page.autocopy -sticky w
···
$limitdiffs != $oldprefs(limitdiffs)} {
reselectline
-
if {$hideremotes != $oldprefs(hideremotes)} {
+
if {$hideremotes != $oldprefs(hideremotes) || $refstohide != $oldprefs(refstohide)} {
rereadrefs
if {$wrapcomment != $oldprefs(wrapcomment)} {
···
return $tcl_enc
+
proc is_other_ref_visible {ref} {
+
global refstohide
+
+
if {$refstohide eq {}} {
+
return 1
+
}
+
+
foreach pat [split $refstohide " "] {
+
if {$pat eq {}} continue
+
if {[string match $pat $ref]} {
+
return 0
+
}
+
}
+
+
return 1
+
}
+
## For msgcat loading, first locate the installation location.
if { [info exists ::env(GITK_MSGSDIR)] } {
## Msgsdir was manually set in the environment.
···
set wrapdefault "none"
set showneartags 1
set hideremotes 0
+
set refstohide ""
set sortrefsbytype 1
set maxrefs 20
set visiblerefs {"master"}
···
mergecolors
perfile_attrs
reflinecolor
+
refstohide
remotebgcolor
selectbgcolor
showlocalchanges