Handle the rename cases reported by git-diff-tree -C correctly.

This commit is contained in:
Paul Mackerras 2005-07-20 12:25:54 -04:00 committed by Paul Mackerras
parent 3c461ffe88
commit 7eab29339b

43
gitk
View file

@ -1861,7 +1861,7 @@ proc gettreediffline {gdtf ids} {
proc getblobdiffs {ids} { proc getblobdiffs {ids} {
global diffopts blobdifffd diffids env curdifftag curtagstart global diffopts blobdifffd diffids env curdifftag curtagstart
global diffindex difffilestart nextupdate diffinhdr global difffilestart nextupdate diffinhdr treediffs
set id [lindex $ids 0] set id [lindex $ids 0]
set p [lindex $ids 1] set p [lindex $ids 1]
@ -1876,7 +1876,6 @@ proc getblobdiffs {ids} {
set blobdifffd($ids) $bdf set blobdifffd($ids) $bdf
set curdifftag Comments set curdifftag Comments
set curtagstart 0.0 set curtagstart 0.0
set diffindex 0
catch {unset difffilestart} catch {unset difffilestart}
fileevent $bdf readable [list getblobdiffline $bdf $diffids] fileevent $bdf readable [list getblobdiffline $bdf $diffids]
set nextupdate [expr {[clock clicks -milliseconds] + 100}] set nextupdate [expr {[clock clicks -milliseconds] + 100}]
@ -1884,8 +1883,8 @@ proc getblobdiffs {ids} {
proc getblobdiffline {bdf ids} { proc getblobdiffline {bdf ids} {
global diffids blobdifffd ctext curdifftag curtagstart global diffids blobdifffd ctext curdifftag curtagstart
global diffnexthead diffnextnote diffindex difffilestart global diffnexthead diffnextnote difffilestart
global nextupdate diffinhdr global nextupdate diffinhdr treediffs
global gaudydiff global gaudydiff
set n [gets $bdf line] set n [gets $bdf line]
@ -1902,18 +1901,29 @@ proc getblobdiffline {bdf ids} {
return return
} }
$ctext conf -state normal $ctext conf -state normal
if {[regexp {^diff --git a/(.*) b/} $line match fname]} { if {[regexp {^diff --git a/(.*) b/(.*)} $line match fname newname]} {
# start of a new file # start of a new file
$ctext insert end "\n" $ctext insert end "\n"
$ctext tag add $curdifftag $curtagstart end $ctext tag add $curdifftag $curtagstart end
set curtagstart [$ctext index "end - 1c"] set curtagstart [$ctext index "end - 1c"]
set header $fname set header $newname
set here [$ctext index "end - 1c"] set here [$ctext index "end - 1c"]
set difffilestart($diffindex) $here set i [lsearch -exact $treediffs($diffids) $fname]
incr diffindex if {$i >= 0} {
# start mark names at fmark.1 for first file set difffilestart($i) $here
$ctext mark set fmark.$diffindex $here incr i
$ctext mark gravity fmark.$diffindex left $ctext mark set fmark.$i $here
$ctext mark gravity fmark.$i left
}
if {$newname != $fname} {
set i [lsearch -exact $treediffs($diffids) $newname]
if {$i >= 0} {
set difffilestart($i) $here
incr i
$ctext mark set fmark.$i $here
$ctext mark gravity fmark.$i left
}
}
set curdifftag "f:$fname" set curdifftag "f:$fname"
$ctext tag delete $curdifftag $ctext tag delete $curdifftag
set l [expr {(78 - [string length $header]) / 2}] set l [expr {(78 - [string length $header]) / 2}]
@ -1973,14 +1983,19 @@ proc nextfile {} {
set here [$ctext index @0,0] set here [$ctext index @0,0]
for {set i 0} {[info exists difffilestart($i)]} {incr i} { for {set i 0} {[info exists difffilestart($i)]} {incr i} {
if {[$ctext compare $difffilestart($i) > $here]} { if {[$ctext compare $difffilestart($i) > $here]} {
$ctext yview $difffilestart($i) if {![info exists pos]
break || [$ctext compare $difffilestart($i) < $pos]} {
set pos $difffilestart($i)
}
} }
} }
if {[info exists pos]} {
$ctext yview $pos
}
} }
proc listboxsel {} { proc listboxsel {} {
global ctext cflist currentid treediffs global ctext cflist currentid
if {![info exists currentid]} return if {![info exists currentid]} return
set sel [lsort [$cflist curselection]] set sel [lsort [$cflist curselection]]
if {$sel eq {}} return if {$sel eq {}} return