Re: [PATCH 3/7] gitk: Allow starting gui blame for a specific line.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Alexander Gavrilov
Date: Saturday, October 25, 2008 - 9:45 am

On Saturday 25 October 2008 15:57:23 Paul Mackerras wrote:

Ugh. I guess I'll have to install docs from Tcl 8.4...
 

Yes, it's probably better to apply the following fixup.

Alexander


diff --git a/gitk b/gitk
index 6fbd6bb..68f07c2 100755
--- a/gitk
+++ b/gitk
@@ -3160,33 +3160,32 @@ proc find_hunk_blamespec {base line} {
 
     # Now scan the lines to determine offset within the hunk
     set parent {}
+    set max_parent [expr {[llength $base_lines]-2}]
     set dline 0
     set s_lno [lindex [split $s_lix "."] 0]
 
     for {set i $line} {$i > $s_lno} {incr i -1} {
 	set c_line [$ctext get $i.0 "$i.0 + 1 lines"]
 	# Determine if the line is removed
-	set chunk [string range $c_line 0 [llength $base_lines]-2]
+	set chunk [string range $c_line 0 $max_parent]
 	set removed_idx [string first "-" $chunk]
 	# Choose a parent index
 	if {$parent eq {}} {
 	    if {$removed_idx >= 0} {
 		set parent $removed_idx
-		incr parent
 	    } else {
 		set unchanged_idx [string first " " $chunk]
 		if {$unchanged_idx >= 0} {
 		    set parent $unchanged_idx
-		    incr parent
 		} else {
 		    # blame the current commit
-		    set parent 0
+		    set parent -1
 		}
 	    }
 	}
 	# then count other lines that belong to it
-	if {$parent > 0} {
-	    set code [string index $c_line $parent-1]
+	if {$parent >= 0} {
+	    set code [string index $c_line $parent]
 	    if {$code eq "-" || ($removed_idx < 0 && $code ne "+")} {
 		incr dline
 	    }
@@ -3197,7 +3196,8 @@ proc find_hunk_blamespec {base line} {
 	}
     }
 
-    if {$parent eq {}} { set parent 0 }
+    if {$parent eq {}} { set parent -1 }
+    incr parent
     incr dline [lindex $base_lines $parent]
     return [list $parent $dline]
 }

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH 0/7] gitk: UI enhancements, Alexander Gavrilov, (Wed Oct 8, 12:05 am)
[PATCH 1/7] gitk: Enhance UI popup and accelerator handling., Alexander Gavrilov, (Wed Oct 8, 12:05 am)
[PATCH 2/7] gitk: Allow forcing branch creation if it alre ..., Alexander Gavrilov, (Wed Oct 8, 12:05 am)
[PATCH 3/7] gitk: Allow starting gui blame for a specific ..., Alexander Gavrilov, (Wed Oct 8, 12:05 am)
[PATCH 4/7] gitk: Fix file list context menu for merge com ..., Alexander Gavrilov, (Wed Oct 8, 12:05 am)
Re: [PATCH 1/7] gitk: Enhance UI popup and accelerator han ..., Alexander Gavrilov, (Thu Oct 9, 1:12 am)
Re: [PATCH 1/7] gitk: Enhance UI popup and accelerator han ..., Alexander Gavrilov, (Thu Oct 16, 3:08 pm)
Re: [PATCH 3/7] gitk: Allow starting gui blame for a speci ..., Alexander Gavrilov, (Fri Oct 24, 1:13 am)
Re: [PATCH 3/7] gitk: Allow starting gui blame for a speci ..., Alexander Gavrilov, (Sat Oct 25, 9:45 am)