[PATCH] gitk: Handle 'copy from' and 'copy to' in diff headers.

If a commit contained a copy operation, the file name was not correctly
determined, and the corresponding part of the patch could not be
navigated to from the list of files.

Signed-off-by: Johannes Sixt <johannes.sixt@telecom.at>
Signed-off-by: Paul Mackerras <paulus@samba.org>
This commit is contained in:
Johannes Sixt 2007-08-16 14:32:29 +02:00 committed by Paul Mackerras
parent d7b16113a1
commit d1cb298b0b

14
gitk
View File

@ -5146,8 +5146,8 @@ proc getblobdiffline {bdf ids} {
# the middle char will be a space, and the two bits either # the middle char will be a space, and the two bits either
# side will be a/name and b/name, or "a/name" and "b/name". # side will be a/name and b/name, or "a/name" and "b/name".
# If the name has changed we'll get "rename from" and # If the name has changed we'll get "rename from" and
# "rename to" lines following this, and we'll use them # "rename to" or "copy from" and "copy to" lines following this,
# to get the filenames. # and we'll use them to get the filenames.
# This complexity is necessary because spaces in the filename(s) # This complexity is necessary because spaces in the filename(s)
# don't get escaped. # don't get escaped.
set l [string length $line] set l [string length $line]
@ -5171,8 +5171,9 @@ proc getblobdiffline {bdf ids} {
set diffinhdr 0 set diffinhdr 0
} elseif {$diffinhdr} { } elseif {$diffinhdr} {
if {![string compare -length 12 "rename from " $line]} { if {![string compare -length 12 "rename from " $line] ||
set fname [string range $line 12 end] ![string compare -length 10 "copy from " $line]} {
set fname [string range $line [expr 6 + [string first " from " $line] ] end]
if {[string index $fname 0] eq "\""} { if {[string index $fname 0] eq "\""} {
set fname [lindex $fname 0] set fname [lindex $fname 0]
} }
@ -5180,8 +5181,9 @@ proc getblobdiffline {bdf ids} {
if {$i >= 0} { if {$i >= 0} {
setinlist difffilestart $i $curdiffstart setinlist difffilestart $i $curdiffstart
} }
} elseif {![string compare -length 10 $line "rename to "]} { } elseif {![string compare -length 10 $line "rename to "] ||
set fname [string range $line 10 end] ![string compare -length 8 $line "copy to "]} {
set fname [string range $line [expr 4 + [string first " to " $line] ] end]
if {[string index $fname 0] eq "\""} { if {[string index $fname 0] eq "\""} {
set fname [lindex $fname 0] set fname [lindex $fname 0]
} }