@matheusbsbs / matheus-bagliano / commits / d1cb298b0b
Fork 0

[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>

Johannes Sixt committed Aug 16, 2007 at 14:32 UTC d1cb298b0b74972cc27c789e4c9ce6f324f25113
1 file changed +8 -6
gitk
+8 -6
@@ -5146,8 +5146,8 @@ proc getblobdiffline {bdf ids} {
5146 # the middle char will be a space, and the two bits either
5147 # side will be a/name and b/name, or "a/name" and "b/name".
5148 # If the name has changed we'll get "rename from" and
5149 - # "rename to" lines following this, and we'll use them
5150 - # to get the filenames.
5149 + # "rename to" or "copy from" and "copy to" lines following this,
5150 + # and we'll use them to get the filenames.
5151 # This complexity is necessary because spaces in the filename(s)
5152 # don't get escaped.
5153 set l [string length $line]
@@ -5171,8 +5171,9 @@ proc getblobdiffline {bdf ids} {
5171 set diffinhdr 0
5172
5173 } elseif {$diffinhdr} {
5174 - if {![string compare -length 12 "rename from " $line]} {
5175 - set fname [string range $line 12 end]
5174 + if {![string compare -length 12 "rename from " $line] ||
5175 + ![string compare -length 10 "copy from " $line]} {
5176 + set fname [string range $line [expr 6 + [string first " from " $line] ] end]
5177 if {[string index $fname 0] eq "\""} {
5178 set fname [lindex $fname 0]
5179 }
@@ -5180,8 +5181,9 @@ proc getblobdiffline {bdf ids} {
5181 if {$i >= 0} {
5182 setinlist difffilestart $i $curdiffstart
5183 }
5183 - } elseif {![string compare -length 10 $line "rename to "]} {
5184 - set fname [string range $line 10 end]
5184 + } elseif {![string compare -length 10 $line "rename to "] ||
5185 + ![string compare -length 8 $line "copy to "]} {
5186 + set fname [string range $line [expr 4 + [string first " to " $line] ] end]
5187 if {[string index $fname 0] eq "\""} {
5188 set fname [lindex $fname 0]
5189 }