Skip to content

Commit

Permalink
[PATCH] gitk: Handle 'copy from' and 'copy to' in diff headers.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Sixt authored and Paul Mackerras committed Aug 17, 2007
1 parent d7b1611 commit d1cb298
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions gitk
Original file line number Diff line number Diff line change
Expand Up @@ -5146,8 +5146,8 @@ proc getblobdiffline {bdf ids} {
# 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".
# If the name has changed we'll get "rename from" and
# "rename to" lines following this, and we'll use them
# to get the filenames.
# "rename to" or "copy from" and "copy to" lines following this,
# and we'll use them to get the filenames.
# This complexity is necessary because spaces in the filename(s)
# don't get escaped.
set l [string length $line]
Expand All @@ -5171,17 +5171,19 @@ proc getblobdiffline {bdf ids} {
set diffinhdr 0

} elseif {$diffinhdr} {
if {![string compare -length 12 "rename from " $line]} {
set fname [string range $line 12 end]
if {![string compare -length 12 "rename from " $line] ||
![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 "\""} {
set fname [lindex $fname 0]
}
set i [lsearch -exact $treediffs($ids) $fname]
if {$i >= 0} {
setinlist difffilestart $i $curdiffstart
}
} elseif {![string compare -length 10 $line "rename to "]} {
set fname [string range $line 10 end]
} elseif {![string compare -length 10 $line "rename to "] ||
![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 "\""} {
set fname [lindex $fname 0]
}
Expand Down

0 comments on commit d1cb298

Please sign in to comment.