This commit is contained in:
Junio C Hamano
2005-11-20 12:18:13 -08:00

101
gitk
View File

@ -218,6 +218,8 @@ proc parsecommit {id contents listed olds} {
set i [string first "\n" $comment] set i [string first "\n" $comment]
if {$i >= 0} { if {$i >= 0} {
set headline [string trim [string range $comment 0 $i]] set headline [string trim [string range $comment 0 $i]]
} else {
set headline $comment
} }
if {!$listed} { if {!$listed} {
# git-rev-list indents the comment by 4 spaces; # git-rev-list indents the comment by 4 spaces;
@ -226,6 +228,7 @@ proc parsecommit {id contents listed olds} {
foreach line [split $comment "\n"] { foreach line [split $comment "\n"] {
append newcomment " " append newcomment " "
append newcomment $line append newcomment $line
append newcomment "\n"
} }
set comment $newcomment set comment $newcomment
} }
@ -238,77 +241,43 @@ proc parsecommit {id contents listed olds} {
proc readrefs {} { proc readrefs {} {
global tagids idtags headids idheads tagcontents global tagids idtags headids idheads tagcontents
global otherrefids idotherrefs
set tags [glob -nocomplain -types f [gitdir]/refs/tags/*] set refd [open [list | git-ls-remote [gitdir]] r]
foreach f $tags { while {0 <= [set n [gets $refd line]]} {
catch { if {![regexp {^([0-9a-f]{40}) refs/([^^]*)$} $line \
set fd [open $f r] match id path]} {
set line [read $fd] continue
if {[regexp {^[0-9a-f]{40}} $line id]} { }
set direct [file tail $f] if {![regexp {^(tags|heads)/(.*)$} $path match type name]} {
set tagids($direct) $id set type others
lappend idtags($id) $direct set name $path
set tagblob [exec git-cat-file tag $id] }
set contents [split $tagblob "\n"] if {$type == "tags"} {
set tagids($name) $id
lappend idtags($id) $name
set obj {} set obj {}
set type {} set type {}
set tag {} set tag {}
foreach l $contents {
if {$l == {}} break
switch -- [lindex $l 0] {
"object" {set obj [lindex $l 1]}
"type" {set type [lindex $l 1]}
"tag" {set tag [string range $l 4 end]}
}
}
if {$obj != {} && $type == "commit" && $tag != {}} {
set tagids($tag) $obj
lappend idtags($obj) $tag
set tagcontents($tag) $tagblob
}
}
close $fd
}
}
set heads [glob -nocomplain -types f [gitdir]/refs/heads/*]
foreach f $heads {
catch { catch {
set fd [open $f r] set commit [exec git-rev-parse "$id^0"]
set line [read $fd 40] if {"$commit" != "$id"} {
if {[regexp {^[0-9a-f]{40}} $line id]} { set tagids($name) $commit
set head [file tail $f] lappend idtags($commit) $name
set headids($head) $line
lappend idheads($line) $head
}
close $fd
} }
} }
readotherrefs refs {} {tags heads}
}
proc readotherrefs {base dname excl} {
global otherrefids idotherrefs
set git [gitdir]
set files [glob -nocomplain -types f [file join $git $base *]]
foreach f $files {
catch { catch {
set fd [open $f r] set tagcontents($name) [exec git-cat-file tag "$id"]
set line [read $fd 40] }
if {[regexp {^[0-9a-f]{40}} $line id]} { } elseif { $type == "heads" } {
set name "$dname[file tail $f]" set headids($name) $id
lappend idheads($id) $name
} else {
set otherrefids($name) $id set otherrefids($name) $id
lappend idotherrefs($id) $name lappend idotherrefs($id) $name
} }
close $fd
}
}
set dirs [glob -nocomplain -types d [file join $git $base *]]
foreach d $dirs {
set dir [file tail $d]
if {[lsearch -exact $excl $dir] >= 0} continue
readotherrefs [file join $base $dir] "$dname$dir/" {}
} }
close $refd
} }
proc error_popup msg { proc error_popup msg {
@ -1537,7 +1506,6 @@ proc drawrest {} {
global numcommits ncmupdate global numcommits ncmupdate
global nextupdate startmsecs revlistorder global nextupdate startmsecs revlistorder
if {!$revlistorder} {
set level [decidenext] set level [decidenext]
if {$level >= 0} { if {$level >= 0} {
set phase drawgraph set phase drawgraph
@ -1550,7 +1518,6 @@ proc drawrest {} {
} }
} }
} }
}
drawmore 0 drawmore 0
set phase {} set phase {}
set drawmsecs [expr [clock clicks -milliseconds] - $startmsecs] set drawmsecs [expr [clock clicks -milliseconds] - $startmsecs]
@ -2821,8 +2788,7 @@ proc gettreediffs {ids} {
set treepending $ids set treepending $ids
set treediff {} set treediff {}
set id [lindex $ids 0] set id [lindex $ids 0]
set p [lindex $ids 1] if [catch {set gdtf [open "|git-diff-tree --no-commit-id -r $id" r]}] return
if [catch {set gdtf [open "|git-diff-tree -r $id" r]}] return
fconfigure $gdtf -blocking 0 fconfigure $gdtf -blocking 0
fileevent $gdtf readable [list gettreediffline $gdtf $ids] fileevent $gdtf readable [list gettreediffline $gdtf $ids]
} }
@ -2856,9 +2822,8 @@ proc getblobdiffs {ids} {
global difffilestart nextupdate diffinhdr treediffs global difffilestart nextupdate diffinhdr treediffs
set id [lindex $ids 0] set id [lindex $ids 0]
set p [lindex $ids 1]
set env(GIT_DIFF_OPTS) $diffopts set env(GIT_DIFF_OPTS) $diffopts
set cmd [list | git-diff-tree -r -p -C $id] set cmd [list | git-diff-tree --no-commit-id -r -p -C $id]
if {[catch {set bdf [open $cmd r]} err]} { if {[catch {set bdf [open $cmd r]} err]} {
puts "error getting diffs: $err" puts "error getting diffs: $err"
return return
@ -3159,7 +3124,7 @@ proc linehover {} {
set t [$canv create rectangle $x0 $y0 $x1 $y1 \ set t [$canv create rectangle $x0 $y0 $x1 $y1 \
-fill \#ffff80 -outline black -width 1 -tags hover] -fill \#ffff80 -outline black -width 1 -tags hover]
$canv raise $t $canv raise $t
set t [$canv create text $x $y -anchor nw -text $text -tags hover] set t [$canv create text $x $y -anchor nw -text $text -tags hover -font $mainfont]
$canv raise $t $canv raise $t
} }
@ -3194,7 +3159,7 @@ proc clickisonarrow {id y} {
} }
proc arrowjump {id dirn y} { proc arrowjump {id dirn y} {
global mainline sidelines canv global mainline sidelines canv canv2 canv3
set yt {} set yt {}
if {$dirn eq "down"} { if {$dirn eq "down"} {
@ -3232,6 +3197,8 @@ proc arrowjump {id dirn y} {
set yfrac 0 set yfrac 0
} }
$canv yview moveto $yfrac $canv yview moveto $yfrac
$canv2 yview moveto $yfrac
$canv3 yview moveto $yfrac
} }
proc lineclick {x y id isnew} { proc lineclick {x y id isnew} {