@@ -387,47 +387,39 @@ proc getcommit {id} {
387
387
}
388
388
389
389
proc readrefs {} {
390
- global tagids idtags headids idheads tagcontents
390
+ global tagids idtags headids idheads tagobjid
391
391
global otherrefids idotherrefs mainhead mainheadid
392
392
393
393
foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
394
394
catch {unset $v }
395
395
}
396
- set refd [open [list | git show-ref] r]
397
- while {0 <= [set n [gets $refd line]]} {
398
- if {![regexp {^([0-9a-f]{40}) refs/([^^]*)$} $line \
399
- match id path]} {
400
- continue
401
- }
402
- if {[regexp {^remotes/.*/HEAD$} $path match]} {
403
- continue
404
- }
405
- if {![regexp {^(tags|heads)/(.*)$} $path match type name]} {
406
- set type others
407
- set name $path
408
- }
409
- if {[regexp {^remotes/} $path match]} {
410
- set type heads
411
- }
412
- if {$type == " tags" } {
413
- set tagids($name ) $id
414
- lappend idtags($id ) $name
415
- set obj {}
416
- set type {}
417
- set tag {}
418
- catch {
419
- set commit [exec git rev-parse " $id ^0" ]
420
- if {$commit != $id } {
421
- set tagids($name ) $commit
422
- lappend idtags($commit ) $name
423
- }
424
- }
425
- catch {
426
- set tagcontents($name ) [exec git cat-file tag $id ]
396
+ set refd [open [list | git show-ref -d] r]
397
+ while {[gets $refd line] >= 0} {
398
+ if {[string index $line 40] ne " " } continue
399
+ set id [string range $line 0 39]
400
+ set ref [string range $line 41 end]
401
+ if {![string match " refs/*" $ref ]} continue
402
+ set name [string range $ref 5 end]
403
+ if {[string match " remotes/*" $name ]} {
404
+ if {![string match " */HEAD" $name ]} {
405
+ set headids($name ) $id
406
+ lappend idheads($id ) $name
427
407
}
428
- } elseif { $type == " heads" } {
408
+ } elseif {[string match " heads/*" $name ]} {
409
+ set name [string range $name 6 end]
429
410
set headids($name ) $id
430
411
lappend idheads($id ) $name
412
+ } elseif {[string match " tags/*" $name ]} {
413
+ # this lets refs/tags/foo^{} overwrite refs/tags/foo,
414
+ # which is what we want since the former is the commit ID
415
+ set name [string range $name 5 end]
416
+ if {[string match " *^{}" $name ]} {
417
+ set name [string range $name 0 end-3]
418
+ } else {
419
+ set tagobjid($name ) $id
420
+ }
421
+ set tagids($name ) $id
422
+ lappend idtags($id ) $name
431
423
} else {
432
424
set otherrefids($name ) $id
433
425
lappend idotherrefs($id ) $name
@@ -6777,14 +6769,19 @@ proc listrefs {id} {
6777
6769
}
6778
6770
6779
6771
proc showtag {tag isnew} {
6780
- global ctext tagcontents tagids linknum
6772
+ global ctext tagcontents tagids linknum tagobjid
6781
6773
6782
6774
if {$isnew } {
6783
6775
addtohistory [list showtag $tag 0]
6784
6776
}
6785
6777
$ctext conf -state normal
6786
6778
clear_ctext
6787
6779
set linknum 0
6780
+ if {![info exists tagcontents($tag )]} {
6781
+ catch {
6782
+ set tagcontents($tag ) [exec git cat-file tag $tagobjid($tag) ]
6783
+ }
6784
+ }
6788
6785
if {[info exists tagcontents($tag )]} {
6789
6786
set text $tagcontents($tag)
6790
6787
} else {
0 commit comments