]> git.ipfire.org Git - thirdparty/git.git/commitdiff
gitk: fix highlighted remote prefix of branches with directories
authorJohannes Sixt <j6t@kdbg.org>
Wed, 14 Jan 2026 18:27:53 +0000 (19:27 +0100)
committerJohannes Sixt <j6t@kdbg.org>
Tue, 20 Jan 2026 16:09:40 +0000 (17:09 +0100)
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>
gitk

diff --git a/gitk b/gitk
index 7f62c8041d1c77788e458c85df687b4690cee662..cbaaee994e0aa8fb1879445f4c704d322da4a6e1 100755 (executable)
--- a/gitk
+++ b/gitk
@@ -6841,7 +6841,7 @@ proc drawtags {id x xt y1} {
             set xl [expr {$xl - $delta/2}]
             $canv create polygon $x $yt $xr $yt $xr $yb $x $yb \
                 -width 1 -outline black -fill $col -tags tag.$id
-            if {[regexp {^(remotes/.*/|remotes/)} $tag match remoteprefix]} {
+            if {[regexp {^(remotes/[^/]*/|remotes/)} $tag match remoteprefix]} {
                 set rwid [font measure mainfont $remoteprefix]
                 set xi [expr {$x + 1}]
                 set yti [expr {$yt + 1}]