Skip to content

Commit 8a48571

Browse files
committed
gitk: Show the currently checked-out head in bold font
Signed-off-by: Paul Mackerras <[email protected]>
1 parent f8a2c0d commit 8a48571

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

gitk

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ proc getcommit {id} {
312312

313313
proc readrefs {} {
314314
global tagids idtags headids idheads tagcontents
315-
global otherrefids idotherrefs
315+
global otherrefids idotherrefs mainhead
316316

317317
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
318318
catch {unset $v}
@@ -358,6 +358,13 @@ proc readrefs {} {
358358
}
359359
}
360360
close $refd
361+
set mainhead {}
362+
catch {
363+
set thehead [exec git symbolic-ref HEAD]
364+
if {[string match "refs/heads/*" $thehead]} {
365+
set mainhead [string range $thehead 11 end]
366+
}
367+
}
361368
}
362369

363370
proc show_error {w top msg} {
@@ -3150,9 +3157,9 @@ proc bindline {t id} {
31503157
}
31513158

31523159
proc drawtags {id x xt y1} {
3153-
global idtags idheads idotherrefs
3160+
global idtags idheads idotherrefs mainhead
31543161
global linespc lthickness
3155-
global canv mainfont commitrow rowtextx curview fgcolor
3162+
global canv mainfont commitrow rowtextx curview fgcolor bgcolor
31563163

31573164
set marks {}
31583165
set ntags 0
@@ -3177,8 +3184,14 @@ proc drawtags {id x xt y1} {
31773184
set yb [expr {$yt + $linespc - 1}]
31783185
set xvals {}
31793186
set wvals {}
3187+
set i -1
31803188
foreach tag $marks {
3181-
set wid [font measure $mainfont $tag]
3189+
incr i
3190+
if {$i >= $ntags && $i < $ntags + $nheads && $tag eq $mainhead} {
3191+
set wid [font measure [concat $mainfont bold] $tag]
3192+
} else {
3193+
set wid [font measure $mainfont $tag]
3194+
}
31823195
lappend xvals $xt
31833196
lappend wvals $wid
31843197
set xt [expr {$xt + $delta + $wid + $lthickness + $linespc}]
@@ -3189,6 +3202,7 @@ proc drawtags {id x xt y1} {
31893202
foreach tag $marks x $xvals wid $wvals {
31903203
set xl [expr {$x + $delta}]
31913204
set xr [expr {$x + $delta + $wid + $lthickness}]
3205+
set font $mainfont
31923206
if {[incr ntags -1] >= 0} {
31933207
# draw a tag
31943208
set t [$canv create polygon $x [expr {$yt + $delta}] $xl $yt \
@@ -3200,6 +3214,9 @@ proc drawtags {id x xt y1} {
32003214
# draw a head or other ref
32013215
if {[incr nheads -1] >= 0} {
32023216
set col green
3217+
if {$tag eq $mainhead} {
3218+
lappend font bold
3219+
}
32033220
} else {
32043221
set col "#ddddff"
32053222
}
@@ -3216,7 +3233,7 @@ proc drawtags {id x xt y1} {
32163233
}
32173234
}
32183235
set t [$canv create text $xl $y1 -anchor w -text $tag -fill $fgcolor \
3219-
-font $mainfont -tags [list tag.$id text]]
3236+
-font $font -tags [list tag.$id text]]
32203237
if {$ntags >= 0} {
32213238
$canv bind $t <1> [list showtag $tag 1]
32223239
}

0 commit comments

Comments
 (0)