Skip to contentSkip to conversation

gitk: new option to hide prefetch refs

PATCH In review Tal Kelrich via GitGitGadget 5 participants 6 messages Aug 24, 2021 – Mar 16, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gitk: new option to hide prefetch refs

From: Tal Kelrich <[email protected]>

The maintenance 'prefetch' task creates refs that mirror remote refs, and in repositories with many branches this can clutter the commit list.

Add a new option to ignore any prefetch refs, enabled by default.

---
gitk: new option to hide prefetch refs

Adding a new option for gitk to ignore prefetch refs, as these clutter the commit list on repositories with many branches.

This defaults to being enabled, as I would expect users usually wouldn't want to see these.

It might have been better to allow gitk to read log.excludeDecoration (or a gitk specific configured pattern) and use that to ignore refs, but this was simpler for me to implement without knowing Tcl.

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1023%2Fhasturkun%2Fgitk-ignore-prefetch-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1023/hasturkun/gitk-ignore-prefetch-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1023

 gitk-git/gitk | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
gitk-git/gitk +16 -7
index 23d9dd1fe0d..4e44da517f2 100755
@@ -1780,6 +1780,7 @@ proc readrefs {} {
     global selecthead selectheadid
     global hideremotes
     global tclencoding
+    global hideprefetch
 
     foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
         unset -nocomplain $v
@@ -1814,6 +1815,7 @@ proc readrefs {} {
             }
             set tagids($name) $id
             lappend idtags($id) $name
+        } elseif {[string match "prefetch/*" $name] && $hideprefetch} {
         } else {
             set otherrefids($name) $id
             lappend idotherrefs($id) $name
@@ -11548,7 +11550,7 @@ proc create_prefs_page {w} {
 proc prefspage_general {notebook} {
     global NS maxwidth maxgraphpct showneartags showlocalchanges
     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk maxrefs web_browser
+    global hideremotes want_ttk have_ttk maxrefs web_browser hideprefetch
 
     set page [create_prefs_page $notebook.general]
 
@@ -11572,6 +11574,9 @@ proc prefspage_general {notebook} {
     ${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
         -variable hideremotes
     grid x $page.hideremotes -sticky w
+    ${NS}::checkbutton $page.hideprefetch -text [mc "Hide prefetch refs"] \
+        -variable hideprefetch
+    grid x $page.hideprefetch -sticky w
 
     ${NS}::label $page.ddisp -text [mc "Diff display options"]
     grid $page.ddisp - -sticky w -pady 10
@@ -11696,7 +11701,7 @@ proc doprefs {} {
     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
+    global hideremotes want_ttk have_ttk hideprefetch
 
     set top .gitkprefs
     set prefstop $top
@@ -11705,7 +11710,8 @@ proc doprefs {} {
         return
     }
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
+                   limitdiffs tabstop perfile_attrs hideremotes want_ttk \
+                   hideprefetch} {
         set oldprefs($v) [set $v]
     }
     ttk_toplevel $top
@@ -11831,7 +11837,8 @@ proc prefscan {} {
     global oldprefs prefstop
 
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
+                   limitdiffs tabstop perfile_attrs hideremotes want_ttk \
+                   hideprefetch} {
         global $v
         set $v $oldprefs($v)
     }
@@ -11845,7 +11852,7 @@ proc prefsok {} {
     global oldprefs prefstop showneartags showlocalchanges
     global fontpref mainfont textfont uifont
     global limitdiffs treediffs perfile_attrs
-    global hideremotes
+    global hideremotes hideprefetch
 
     catch {destroy $prefstop}
     unset prefstop
@@ -11891,7 +11898,8 @@ proc prefsok {} {
           $limitdiffs != $oldprefs(limitdiffs)} {
         reselectline
     }
-    if {$hideremotes != $oldprefs(hideremotes)} {
+    if {$hideremotes != $oldprefs(hideremotes) ||
+          $hideprefetch != $oldprefs(hideprefetch)} {
         rereadrefs
     }
 }
@@ -12365,6 +12373,7 @@ set cmitmode "patch"
 set wrapcomment "none"
 set showneartags 1
 set hideremotes 0
+set hideprefetch 1
 set maxrefs 20
 set visiblerefs {"master"}
 set maxlinelen 200
@@ -12477,7 +12486,7 @@ set config_variables {
     filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
     linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
     indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors
-    web_browser
+    web_browser hideprefetch
 }
 foreach var $config_variables {
     config_init_trace $var

base-commit: 225bc32a989d7a22fa6addafd4ce7dcd04675dbf

Signature · 1 line
gitgitgadget
#1 lore raw
Quoted 6 lines · Tal Kelrich via GitGitGadget

From: Tal Kelrich <[email protected]>

The maintenance 'prefetch' task creates refs that mirror remote refs, and in repositories with many branches this can clutter the commit list.

Add a new option to ignore any prefetch refs, enabled by default.

This seems like a sensible feature to add. Thank you for contributing!

Quoted 3 lines

It might have been better to allow gitk to read log.excludeDecoration (or a gitk specific configured pattern) and use that to ignore refs, but this was simpler for me to implement without knowing Tcl.

I agree, but I also don't know Tcl so can't comment to how hard that might be. I'm not sure how gitk operates and why it does not automatically benefit from log.excludeDecoration. Is it computing its own decoration? Is it using a different Git command that isn't integrated with log.excludeDecoration, but should be?

I also cannot review that this patch works as advertised. I just wanted to chime in with support for the idea.

Thanks,
-Stolee

#2 lore raw
Quoted 14 lines · Derrick Stolee
Quoted 6 lines · Tal Kelrich via GitGitGadget

From: Tal Kelrich <[email protected]>

The maintenance 'prefetch' task creates refs that mirror remote refs, and in repositories with many branches this can clutter the commit list.

Add a new option to ignore any prefetch refs, enabled by default.

This seems like a sensible feature to add. Thank you for contributing!

Quoted 3 lines

It might have been better to allow gitk to read log.excludeDecoration (or a gitk specific configured pattern) and use that to ignore refs, but this was simpler for me to implement without knowing Tcl.

Quoted 8 lines

I agree, but I also don't know Tcl so can't comment to how hard that might be. I'm not sure how gitk operates and why it does not automatically benefit from log.excludeDecoration. Is it computing its own decoration? Is it using a different Git command that isn't integrated with log.excludeDecoration, but should be?

I also cannot review that this patch works as advertised. I just wanted to chime in with support for the idea.

I would usually say that defaulting this to 'on' would be a biased choice [*1*], but in this case I tend to think it is a good idea to hide these by default, as 'prefetch' came way after people started using Git, and users did not ask for 'prefetch' refs. The prefetching may help users but the refs used to anchor the prefetched objects are implementation detail that the users would rather not to see.

I wonder if we should also hide refs/stash for the same reason, but that is outside the scope of this change.

In any case, please make it a patch relative to Paul's tree and send it in his direction.

Thanks.

[Footnote]

*1* Whenever the inventor of a feature says "I expect users would want this!", it needs to be taken with a moderate amount of salt, as the inventor is self selected specimen who wanted it (after all, the feature motivated the inventor enough to write the patch).

#3 lore raw
Quoted 11 lines · Junio C Hamano
Quoted 9 lines · Derrick Stolee
Quoted 6 lines · Tal Kelrich via GitGitGadget

From: Tal Kelrich <[email protected]>

The maintenance 'prefetch' task creates refs that mirror remote refs, and in repositories with many branches this can clutter the commit list.

Add a new option to ignore any prefetch refs, enabled by default.

This seems like a sensible feature to add. Thank you for contributing!

...> I would usually say that defaulting this to 'on' would be a biased

Quoted 5 lines

choice [*1*], but in this case I tend to think it is a good idea to hide these by default, as 'prefetch' came way after people started using Git, and users did not ask for 'prefetch' refs. The prefetching may help users but the refs used to anchor the prefetched objects are implementation detail that the users would rather not to see.

...

Quoted 4 lines

*1* Whenever the inventor of a feature says "I expect users would want this!", it needs to be taken with a moderate amount of salt, as the inventor is self selected specimen who wanted it (after all, the feature motivated the inventor enough to write the patch).

I agree with both points. As the inventor of prefetch refs, my opinion should also be taken with similar salt.

I do want to add at least that Git itself hides these refs by modifying log.excludeDecoration during 'git maintenance start', so there is precedent. Git is hiding them, but user can become confused when they appear in gitk.

Thanks,
-Stolee

#4 lore raw

PATCH v3 1/1 gitk: new option to hide prefetch refs

In reply to Tal Kelrich via GitGitGadget

The maintenance 'prefetch' task creates refs that mirror remote refs, and in repositories with many branches this can clutter the commit list.

Add a new option to ignore any prefetch refs, enabled by default.

---
Changes since v1:
- Patch rebuilt on gitk tree.

 gitk | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
gitk +16 -7
index 0ae7d68..85315df 100755
@@ -1780,6 +1780,7 @@ proc readrefs {} {
     global selecthead selectheadid
     global hideremotes
     global tclencoding
+    global hideprefetch
 
     foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
         unset -nocomplain $v
@@ -1814,6 +1815,7 @@ proc readrefs {} {
             }
             set tagids($name) $id
             lappend idtags($id) $name
+        } elseif {[string match "prefetch/*" $name] && $hideprefetch} {
         } else {
             set otherrefids($name) $id
             lappend idotherrefs($id) $name
@@ -11551,7 +11553,7 @@ proc create_prefs_page {w} {
 proc prefspage_general {notebook} {
     global NS maxwidth maxgraphpct showneartags showlocalchanges
     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk maxrefs web_browser
+    global hideremotes want_ttk have_ttk maxrefs web_browser hideprefetch
 
     set page [create_prefs_page $notebook.general]
 
@@ -11575,6 +11577,9 @@ proc prefspage_general {notebook} {
     ${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
         -variable hideremotes
     grid x $page.hideremotes -sticky w
+    ${NS}::checkbutton $page.hideprefetch -text [mc "Hide prefetch refs"] \
+        -variable hideprefetch
+    grid x $page.hideprefetch -sticky w
 
     ${NS}::label $page.ddisp -text [mc "Diff display options"]
     grid $page.ddisp - -sticky w -pady 10
@@ -11699,7 +11704,7 @@ proc doprefs {} {
     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
+    global hideremotes want_ttk have_ttk hideprefetch
 
     set top .gitkprefs
     set prefstop $top
@@ -11708,7 +11713,8 @@ proc doprefs {} {
         return
     }
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
+                   limitdiffs tabstop perfile_attrs hideremotes want_ttk \
+                   hideprefetch} {
         set oldprefs($v) [set $v]
     }
     ttk_toplevel $top
@@ -11834,7 +11840,8 @@ proc prefscan {} {
     global oldprefs prefstop
 
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
+                   limitdiffs tabstop perfile_attrs hideremotes want_ttk \
+                   hideprefetch} {
         global $v
         set $v $oldprefs($v)
     }
@@ -11848,7 +11855,7 @@ proc prefsok {} {
     global oldprefs prefstop showneartags showlocalchanges
     global fontpref mainfont textfont uifont
     global limitdiffs treediffs perfile_attrs
-    global hideremotes
+    global hideremotes hideprefetch
 
     catch {destroy $prefstop}
     unset prefstop
@@ -11894,7 +11901,8 @@ proc prefsok {} {
           $limitdiffs != $oldprefs(limitdiffs)} {
         reselectline
     }
-    if {$hideremotes != $oldprefs(hideremotes)} {
+    if {$hideremotes != $oldprefs(hideremotes) ||
+          $hideprefetch != $oldprefs(hideprefetch)} {
         rereadrefs
     }
 }
@@ -12368,6 +12376,7 @@ set cmitmode "patch"
 set wrapcomment "none"
 set showneartags 1
 set hideremotes 0
+set hideprefetch 1
 set maxrefs 20
 set visiblerefs {"master"}
 set maxlinelen 200
@@ -12480,7 +12489,7 @@ set config_variables {
     filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
     linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
     indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors
-    web_browser
+    web_browser hideprefetch
 }
 foreach var $config_variables {
     config_init_trace $var
Signature · 1 line
2.37.1.windows.1
#5 lore raw

Hi Tal,

I'm Cc:ing the new gitk maintainer, for visibility.

Ciao,
Johannes

Quoted 121 lines · Tal Kelrich

The maintenance 'prefetch' task creates refs that mirror remote refs, and in repositories with many branches this can clutter the commit list.

Add a new option to ignore any prefetch refs, enabled by default.

---
Changes since v1:
- Patch rebuilt on gitk tree.

 gitk | 23 ++++++++++++++++-------
 1 file changed, 16 insertions(+), 7 deletions(-)
gitk +16 -8
index 0ae7d68..85315df 100755
@@ -1780,6 +1780,7 @@ proc readrefs {} {
     global selecthead selectheadid
     global hideremotes
     global tclencoding
+    global hideprefetch
 
     foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
         unset -nocomplain $v
@@ -1814,6 +1815,7 @@ proc readrefs {} {
             }
             set tagids($name) $id
             lappend idtags($id) $name
+        } elseif {[string match "prefetch/*" $name] && $hideprefetch} {
         } else {
             set otherrefids($name) $id
             lappend idotherrefs($id) $name
@@ -11551,7 +11553,7 @@ proc create_prefs_page {w} {
 proc prefspage_general {notebook} {
     global NS maxwidth maxgraphpct showneartags showlocalchanges
     global tabstop limitdiffs autoselect autosellen extdifftool perfile_attrs
-    global hideremotes want_ttk have_ttk maxrefs web_browser
+    global hideremotes want_ttk have_ttk maxrefs web_browser hideprefetch
 
     set page [create_prefs_page $notebook.general]
 
@@ -11575,6 +11577,9 @@ proc prefspage_general {notebook} {
     ${NS}::checkbutton $page.hideremotes -text [mc "Hide remote refs"] \
         -variable hideremotes
     grid x $page.hideremotes -sticky w
+    ${NS}::checkbutton $page.hideprefetch -text [mc "Hide prefetch refs"] \
+        -variable hideprefetch
+    grid x $page.hideprefetch -sticky w
 
     ${NS}::label $page.ddisp -text [mc "Diff display options"]
     grid $page.ddisp - -sticky w -pady 10
@@ -11699,7 +11704,7 @@ proc doprefs {} {
     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
+    global hideremotes want_ttk have_ttk hideprefetch
 
     set top .gitkprefs
     set prefstop $top
@@ -11708,7 +11713,8 @@ proc doprefs {} {
         return
     }
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
+                   limitdiffs tabstop perfile_attrs hideremotes want_ttk \
+                   hideprefetch} {
         set oldprefs($v) [set $v]
     }
     ttk_toplevel $top
@@ -11834,7 +11840,8 @@ proc prefscan {} {
     global oldprefs prefstop
 
     foreach v {maxwidth maxgraphpct showneartags showlocalchanges \
-                   limitdiffs tabstop perfile_attrs hideremotes want_ttk} {
+                   limitdiffs tabstop perfile_attrs hideremotes want_ttk \
+                   hideprefetch} {
         global $v
         set $v $oldprefs($v)
     }
@@ -11848,7 +11855,7 @@ proc prefsok {} {
     global oldprefs prefstop showneartags showlocalchanges
     global fontpref mainfont textfont uifont
     global limitdiffs treediffs perfile_attrs
-    global hideremotes
+    global hideremotes hideprefetch
 
     catch {destroy $prefstop}
     unset prefstop
@@ -11894,7 +11901,8 @@ proc prefsok {} {
           $limitdiffs != $oldprefs(limitdiffs)} {
         reselectline
     }
-    if {$hideremotes != $oldprefs(hideremotes)} {
+    if {$hideremotes != $oldprefs(hideremotes) ||
+          $hideprefetch != $oldprefs(hideprefetch)} {
         rereadrefs
     }
 }
@@ -12368,6 +12376,7 @@ set cmitmode "patch"
 set wrapcomment "none"
 set showneartags 1
 set hideremotes 0
+set hideprefetch 1
 set maxrefs 20
 set visiblerefs {"master"}
 set maxlinelen 200
@@ -12480,7 +12489,7 @@ set config_variables {
     filesepbgcolor filesepfgcolor linehoverbgcolor linehoverfgcolor
     linehoveroutlinecolor mainheadcirclecolor workingfilescirclecolor
     indexcirclecolor circlecolors linkfgcolor circleoutlinecolor diffbgcolors
-    web_browser
+    web_browser hideprefetch
 }
 foreach var $config_variables {
     config_init_trace $var
--

2.37.1.windows.1