gitk: fix highlighted remote prefix of branches with directories
The decoration of a remote ref is colored in two parts: (1) the prefix that mentions the remove (including "remote/"); and (2) the branch name. To extract the prefix from the ref name, a regular expression is used. However, the expression is not restrictive enough: it picks everything before the last slash character as prefix, so that, for example, the ref name "remotes/orgin/ml/themes" is split into "remotes/origin/ml" and "themes". Tighten the regular expression so that only the name of the remote is pulled into the prefix, but no part of the branch name. This gives the desired result in the example: "remotes/origin" and "ml/themes". Signed-off-by: Johannes Sixt <j6t@kdbg.org>
Johannes Sixt committed
Jan 14, 2026 at 19:27 UTC
28f96e0173b4de1543ce45978837ddc49b532a83
1 file changed
+1
-1
gitk
+1
-1
@@ -6841,7 +6841,7 @@ proc drawtags {id x xt y1} {
6841
set xl [expr {$xl - $delta/2}]
6842
$canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
6843
-width 1 -outline black -fill $col -tags tag.$id
6844
- if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
6844
+ if {[regexp {^(remotes/[^/]*/|remotes/)} $tag match remoteprefix]} {
6845
set rwid [font measure mainfont $remoteprefix]
6846
set xi [expr {$x + 1}]
6847
set yti [expr {$yt + 1}]