dashboard / ilyagr/gitk / gitk: Add user preference to hide custom references #71 rss

closed · opened on 2025-08-03T05:37:21Z by ilyagr
Help
checkout latest patchset:
ssh pr.pico.sh print pr-71 | git am -3
checkout any patchset in a patch request:
ssh pr.pico.sh print ps-X | git am -3
add changes to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add 71
add review to patch request:
git format-patch main --stdout | ssh pr.pico.sh pr add --review 71
accept PR:
ssh pr.pico.sh pr accept 71
close PR:
ssh pr.pico.sh pr close 71

Logs

ilyagr created pr with ps-140 on 2025-08-03T05:37:21Z
ilyagr added ps-141 on 2025-08-03T05:40:15Z
ilyagr changed status on 2025-08-03T05:45:12Z {"status":"closed"}

Patchsets

ps-140 by ilyagr on 2025-08-03T05:37:21Z
Range Diff ↕ rd-141
1: 4a4a512 ! 1: 2441e19 gitk: Add user preference to hide specific references
ps-141 by ilyagr on 2025-08-03T05:40:15Z

Range-diff rd-141

title
gitk: Add user preference to hide specific references
description
Patch changed
old #1
4a4a512
new #1
2441e19
Back to top
1: 4a4a512 ! 1: 2441e19 gitk: Add user preference to hide specific references
gitk gitk
     global otherrefids idotherrefs mainhead mainheadid
     global selecthead selectheadid
     global hideremotes
+    global hidecustomrefs
     global tclencoding
 
     foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
             set tagids($name) $id
             lappend idtags($id) $name
         } else {
+            if {$hidecustomrefs} {
+                if {![string match "stash" $ref] ||
+                    ![string match "replace/*" $ref]} continue
+            }
             set otherrefids($name) $id
             lappend idotherrefs($id) $name
         }
     global NS maxwidth maxgraphpct showneartags showlocalchanges
     global tabstop wrapcomment wrapdefault limitdiffs
     global autocopy autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk maxrefs web_browser
+    global hideremotes hidecustomrefs want_ttk have_ttk maxrefs web_browser
 
     set page [create_prefs_page $notebook.general]
 
     ${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
         -variable hideremotes
     grid x $page.hideremotes -sticky w
+    ${NS}::checkbutton $page.hidecustomrefs -text [mc "Hide custom refs"] \
+        -variable hidecustomrefs
+    grid x $page.hidecustomrefs -sticky w
 
     ${NS}::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
         -variable autocopy
     global oldprefs prefstop showneartags showlocalchanges
     global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk wrapcomment wrapdefault
+    global hideremotes hidecustomrefs want_ttk have_ttk wrapcomment wrapdefault
 
     set top .gitkprefs
     set prefstop $top
         return
     }
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
+                   limitdiffs tabstop perfile_attrs hideremotes hidecustomrefs \
+                   want_ttk wrapcomment wrapdefault} {
         set oldprefs($v) [set $v]
     }
     ttk_toplevel $top
     global oldprefs prefstop
 
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
+                   limitdiffs tabstop perfile_attrs hideremotes hidecustomrefs \
+                   want_ttk wrapcomment wrapdefault} {
         global $v
         set $v $oldprefs($v)
     }
     global oldprefs prefstop showneartags showlocalchanges
     global fontpref mainfont textfont uifont
     global limitdiffs treediffs perfile_attrs
-    global hideremotes wrapcomment wrapdefault
+    global hideremotes hidecustomrefs wrapcomment wrapdefault
     global ctext
 
     catch {destroy $prefstop}
           $limitdiffs != $oldprefs(limitdiffs)} {
         reselectline
     }
-    if {$hideremotes != $oldprefs(hideremotes)} {
+    if {$hideremotes != $oldprefs(hideremotes) || $hidecustomrefs != $oldprefs(hidecustomrefs)} {
         rereadrefs
     }
     if {$wrapcomment != $oldprefs(wrapcomment)} {
 set wrapdefault "none"
 set showneartags 1
 set hideremotes 0
+set hidecustomrefs 0
 set maxrefs 20
 set visiblerefs {"master"}
 set maxlinelen 200
     mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
     cmitmode wrapcomment wrapdefault autocopy autoselect autosellen
     showneartags maxrefs visiblerefs
-    hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
+    hideremotes hidecustomrefs showlocalchanges datetimeformat limitdiffs uicolor want_ttk
     bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
     markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor
     extdifftool perfile_attrs headbgcolor headfgcolor headoutlinecolor
gitk 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}
     global NS maxwidth maxgraphpct showneartags showlocalchanges
     global tabstop wrapcomment wrapdefault limitdiffs
     global autocopy autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk maxrefs web_browser
+    global hideremotes refstohide want_ttk have_ttk maxrefs web_browser
 
     set page [create_prefs_page $notebook.general]
 
         -variable hideremotes
     grid x $page.hideremotes -sticky w
 
+    ${NS}::entry $page.refstohide -textvariable refstohide
+    ${NS}::frame $page.refstohidef
+    ${NS}::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
+
     ${NS}::checkbutton $page.autocopy -text [mc "Copy commit ID to clipboard"] \
         -variable autocopy
     grid x $page.autocopy -sticky w
     global oldprefs prefstop showneartags showlocalchanges
     global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor
     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk wrapcomment wrapdefault
+    global hideremotes refstohide want_ttk have_ttk wrapcomment wrapdefault
 
     set top .gitkprefs
     set prefstop $top
         return
     }
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
+                   limitdiffs tabstop perfile_attrs hideremotes refstohide \
+                   want_ttk wrapcomment wrapdefault} {
         set oldprefs($v) [set $v]
     }
     ttk_toplevel $top
     global oldprefs prefstop
 
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk wrapcomment wrapdefault} {
+                   limitdiffs tabstop perfile_attrs hideremotes refstohide \
+                   want_ttk wrapcomment wrapdefault} {
         global $v
         set $v $oldprefs($v)
     }
     global oldprefs prefstop showneartags showlocalchanges
     global fontpref mainfont textfont uifont
     global limitdiffs treediffs perfile_attrs
-    global hideremotes wrapcomment wrapdefault
+    global hideremotes refstohide wrapcomment wrapdefault
     global ctext
 
     catch {destroy $prefstop}
           $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 maxrefs 20
 set visiblerefs {"master"}
 set maxlinelen 200
     mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth
     cmitmode wrapcomment wrapdefault autocopy autoselect autosellen
     showneartags maxrefs visiblerefs
-    hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk
+    hideremotes refstohide showlocalchanges datetimeformat limitdiffs uicolor want_ttk
     bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors
     markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor
     extdifftool perfile_attrs headbgcolor headfgcolor headoutlinecolor