{"thread":{"id":"60582","subject":"[PATCH] gitk: add setting to hide unknown refs","startedAt":"2023-12-04T13:18:23Z","lastAt":"2023-12-08T21:13:12Z","messageCount":2,"participants":["Joachim B Haga via GitGitGadget","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"485349","messageId":"pull.1619.git.1701695899635.gitgitgadget@gmail.com","threadId":"60582","inReplyTo":null,"subject":"[PATCH] gitk: add setting to hide unknown refs","fromName":"Joachim B Haga via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2023-12-04T13:18:19Z","receivedAt":"2023-12-04T13:18:23Z","isPatch":true,"sender":{"key":"cjhaga@fys.uio.no","avatar":null},"body":"From: Joachim B Haga <jobh@simula.no>\n\nTools such as branchless (https://github.com/arxanas/git-branchless)\nadd a lot of refs under the \"refs/branchless\" prefix. By default,\nthese are filtered out from `git log` using the `log.excludeDecoration`\nconfig directive.\n\nHowever, gitk applies decoration itself from the output of `git show-ref`,\nso these refs clutter up the UI.\n\nThis patch adds a setting to gitk to exclude all unknown refs - which\nis considerably simpler than trying to honour the `excludeDecoration`\npattern. Note that this also hides f.x. the `git bisect` refs, which I\nthink is fine given that this behaviour is opt-in (it defaults to not\nhide anything).\n\nSigned-off-by: Joachim B Haga <jobh@simula.no>\n---\n    gitk: add setting to hide unknown refs\n    \n    Tools such as branchless (https://github.com/arxanas/git-branchless) add\n    a lot of refs under the \"refs/branchless\" prefix. By default, these are\n    filtered out from git log using the log.excludeDecoration config\n    directive.\n    \n    However, gitk applies decoration itself from the output of git show-ref,\n    so these refs clutter up the UI.\n    \n    This patch adds a setting to gitk to exclude all unknown refs - which is\n    considerably simpler than trying to honour the excludeDecoration\n    pattern. Note that this also hides f.x. the git bisect refs, which I\n    think is fine given that this behaviour is opt-in (defaults to not hide\n    anything).\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1619%2Fjobh%2Fmaster-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1619/jobh/master-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1619\n\n gitk-git/gitk | 26 ++++++++++++++++----------\n 1 file changed, 16 insertions(+), 10 deletions(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex df3ba2ea99b..e91856b33a0 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -1798,7 +1798,7 @@ proc readrefs {} {\n     global tagids idtags headids idheads tagobjid\n     global otherrefids idotherrefs mainhead mainheadid\n     global selecthead selectheadid\n-    global hideremotes\n+    global hideremotes hideunknown\n     global tclencoding\n \n     foreach v {tagids idtags headids idheads otherrefids idotherrefs} {\n@@ -1835,8 +1835,10 @@ proc readrefs {} {\n             set tagids($name) $id\n             lappend idtags($id) $name\n         } else {\n-            set otherrefids($name) $id\n-            lappend idotherrefs($id) $name\n+\t    if {[string match \"stash\" $name] || !$hideunknown} {\n+\t\tset otherrefids($name) $id\n+\t\tlappend idotherrefs($id) $name\n+\t    }\n         }\n     }\n     catch {close $refd}\n@@ -11577,7 +11579,7 @@ proc create_prefs_page {w} {\n proc prefspage_general {notebook} {\n     global NS maxwidth maxgraphpct showneartags showlocalchanges\n     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs\n-    global hideremotes want_ttk have_ttk maxrefs web_browser\n+    global hideremotes hideunknown want_ttk have_ttk maxrefs web_browser\n \n     set page [create_prefs_page $notebook.general]\n \n@@ -11601,6 +11603,9 @@ proc prefspage_general {notebook} {\n     ${NS}::checkbutton $page.hideremotes -text [mc \"Hide remote refs\"] \\\n         -variable hideremotes\n     grid x $page.hideremotes -sticky w\n+    ${NS}::checkbutton $page.hideunknown -text [mc \"Hide unknown refs\"] \\\n+        -variable hideunknown\n+    grid x $page.hideunknown -sticky w\n \n     ${NS}::label $page.ddisp -text [mc \"Diff display options\"]\n     grid $page.ddisp - -sticky w -pady 10\n@@ -11725,7 +11730,7 @@ proc doprefs {} {\n     global oldprefs prefstop showneartags showlocalchanges\n     global uicolor bgcolor fgcolor ctext diffcolors selectbgcolor markbgcolor\n     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs\n-    global hideremotes want_ttk have_ttk\n+    global hideremotes hideunknown want_ttk have_ttk\n \n     set top .gitkprefs\n     set prefstop $top\n@@ -11734,7 +11739,7 @@ proc doprefs {} {\n         return\n     }\n     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \\\n-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {\n+                   limitdiffs tabstop perfile_attrs hideremotes hideunknown want_ttk} {\n         set oldprefs($v) [set $v]\n     }\n     ttk_toplevel $top\n@@ -11860,7 +11865,7 @@ proc prefscan {} {\n     global oldprefs prefstop\n \n     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \\\n-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {\n+                   limitdiffs tabstop perfile_attrs hideremotes hideunknown want_ttk} {\n         global $v\n         set $v $oldprefs($v)\n     }\n@@ -11874,7 +11879,7 @@ proc prefsok {} {\n     global oldprefs prefstop showneartags showlocalchanges\n     global fontpref mainfont textfont uifont\n     global limitdiffs treediffs perfile_attrs\n-    global hideremotes\n+    global hideremotes hideunknown\n \n     catch {destroy $prefstop}\n     unset prefstop\n@@ -11920,7 +11925,7 @@ proc prefsok {} {\n           $limitdiffs != $oldprefs(limitdiffs)} {\n         reselectline\n     }\n-    if {$hideremotes != $oldprefs(hideremotes)} {\n+    if {$hideremotes != $oldprefs(hideremotes) || $hideunknown != $oldprefs(hideunknown)} {\n         rereadrefs\n     }\n }\n@@ -12394,6 +12399,7 @@ set cmitmode \"patch\"\n set wrapcomment \"none\"\n set showneartags 1\n set hideremotes 0\n+set hideunknown 0\n set maxrefs 20\n set visiblerefs {\"master\"}\n set maxlinelen 200\n@@ -12498,7 +12504,7 @@ config_check_tmp_exists 50\n set config_variables {\n     mainfont textfont uifont tabstop findmergefiles maxgraphpct maxwidth\n     cmitmode wrapcomment autoselect autosellen showneartags maxrefs visiblerefs\n-    hideremotes showlocalchanges datetimeformat limitdiffs uicolor want_ttk\n+    hideremotes hideunknown showlocalchanges datetimeformat limitdiffs uicolor want_ttk\n     bgcolor fgcolor uifgcolor uifgdisabledcolor colors diffcolors mergecolors\n     markbgcolor diffcontext selectbgcolor foundbgcolor currentsearchhitbgcolor\n     extdifftool perfile_attrs headbgcolor headfgcolor headoutlinecolor\n\nbase-commit: 564d0252ca632e0264ed670534a51d18a689ef5d\n-- \ngitgitgadget\n"},{"id":"485482","messageId":"xmqqil581jq4.fsf@gitster.g","threadId":"60582","inReplyTo":"pull.1619.git.1701695899635.gitgitgadget@gmail.com","subject":"Re: [PATCH] gitk: add setting to hide unknown refs","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2023-12-08T21:13:07Z","receivedAt":"2023-12-08T21:13:12Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Joachim B Haga via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> This patch adds a setting to gitk to exclude all unknown refs - which\n> is considerably simpler than trying to honour the `excludeDecoration`\n> pattern.\n\n\"This was simpler to implement\" is a one-time cost savings for the\ndeveloper who added the feature.  For that one-time cost savings,\nall the current and future users will pay the price of inconsistent\nbehaviour between \"gitk\" and \"git log\".\n\nIt does not look like a good trade-off.\n"}]}