Merge branch 'oa/hide-more-refs'

* oa/hide-more-refs:
  gitk: Add user preference to hide specific references

Signed-off-by: Johannes Sixt <j6t@kdbg.org>
This commit is contained in:
Johannes Sixt
2025-08-01 18:38:08 +02:00

34
gitk
View File

@@ -2033,8 +2033,10 @@ proc readrefs {} {
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}
@@ -11649,6 +11651,13 @@ proc prefspage_general {notebook} {
-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
@@ -11983,7 +11992,7 @@ proc prefsok {} {
$limitdiffs != $oldprefs(limitdiffs)} {
reselectline
}
if {$hideremotes != $oldprefs(hideremotes)} {
if {$hideremotes != $oldprefs(hideremotes) || $refstohide != $oldprefs(refstohide)} {
rereadrefs
}
if {$wrapcomment != $oldprefs(wrapcomment)} {
@@ -12360,6 +12369,23 @@ proc get_path_encoding {path} {
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.
@@ -12467,6 +12493,7 @@ set wrapcomment "none"
set wrapdefault "none"
set showneartags 1
set hideremotes 0
set refstohide ""
set sortrefsbytype 1
set maxrefs 20
set visiblerefs {"master"}
@@ -12610,6 +12637,7 @@ set config_variables {
mergecolors
perfile_attrs
reflinecolor
refstohide
remotebgcolor
selectbgcolor
showlocalchanges