git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Sixt <johannes.sixt@telecom.at>
Date
Aug 16, 2007, 12:32 UTC
Message-ID
<11872675493132-git-send-email-johannes.sixt@telecom.at>

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>
---
 gitk |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/gitk b/gitk
index 57617d5..07b4a26 100755
--- a/gitk
+++ b/gitk
@@ -5116,8 +5116,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]
@@ -5141,8 +5141,9 @@ 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]
 		}
@@ -5150,8 +5151,9 @@ proc getblobdiffline {bdf ids} {
 		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]
 		}
-- 
1.5.3.rc5.15.g8ddb
Message 1 of 1 in “gitk: Handle 'copy from' and 'copy to' in diff headers.”
  1. gitk: Handle 'copy from' and 'copy to' in diff headers.Johannes Sixt, Aug 16, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.