[PATCH] gitk: blame older file in case of copied and renamed files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



If file was renamed or copied, and in the same time edited, attempt to run
"Show origin of this line" or "Run gui blame on this line" would result in
error "fatal: no such path FILE in HASH". Reason is that it tried to use
the newer filename, while it should use the older one.

Since ctext_file_names in diff mode only used for parent commit
filenames, there is no need to split it to 2 lists, just change its
so that for diff mode it means older filename always.

Signed-off-by: Max Kirillov <max@xxxxxxxxxx>
---
 gitk | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/gitk b/gitk
index d3e9e459c3..0b8b1a4e9f 100755
--- a/gitk
+++ b/gitk
@@ -8349,9 +8349,16 @@ proc setinlist {var i val} {
     }
 }
 
+proc add_ctext_file {fname} {
+    global ctext_file_names
+
+    set fname [encoding convertfrom $fname]
+    lset ctext_file_names end $fname
+}
+
 proc makediffhdr {fname ids} {
     global ctext curdiffstart treediffs diffencoding
-    global ctext_file_names jump_to_here targetline diffline
+    global jump_to_here targetline diffline
 
     set fname [encoding convertfrom $fname]
     set diffencoding [get_path_encoding $fname]
@@ -8359,7 +8366,6 @@ proc makediffhdr {fname ids} {
     if {$i >= 0} {
 	setinlist difffilestart $i $curdiffstart
     }
-    lset ctext_file_names end $fname
     set l [expr {(78 - [string length $fname]) / 2}]
     set pad [string range "----------------------------------------" 1 $l]
     $ctext insert $curdiffstart "$pad $fname $pad" filesep
@@ -8454,6 +8460,7 @@ proc parseblobdiffline {ids line} {
 		set fname [string range $line 2 [expr {$i - 1}]]
 	    }
 	}
+	add_ctext_file $fname
 	makediffhdr $fname $ids
 
     } elseif {![string compare -length 16 "* Unmerged path " $line]} {
@@ -8492,6 +8499,7 @@ proc parseblobdiffline {ids line} {
 	lappend ctext_file_names ""
 	if {$currdiffsubmod != $fname} {
 	    lappend ctext_file_lines $fname
+	    add_ctext_file $fname
 	    makediffhdr $fname $ids
 	    set currdiffsubmod $fname
 	    $ctext insert end "\n$line\n" filesep
@@ -8512,11 +8520,18 @@ proc parseblobdiffline {ids line} {
 	    if {[string index $fname 0] eq "\""} {
 		set fname [lindex $fname 0]
 	    }
+	    add_ctext_file $fname
 	    set fname [encoding convertfrom $fname]
 	    set i [lsearch -exact $treediffs($ids) $fname]
 	    if {$i >= 0} {
 		setinlist difffilestart $i $curdiffstart
 	    }
+	} elseif {![string compare -length 10 $line "copy from "]} {
+	    set fname [string range $line [expr 6 + [string first " from " $line] ] end]
+	    if {[string index $fname 0] eq "\""} {
+		set fname [lindex $fname 0]
+	    }
+	    add_ctext_file $fname
 	} 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]
-- 
2.11.0.1122.gc3fec58.dirty




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]