@matheusbsbs / matheus-bagliano / commits / 48a81b7cda
Fork 0

gitk: Cope with unmerged files in local changes

This modifies gettreediffline so that it when we get both a "U" line and an "M" line for the same file in the output from git diff-files or git diff-index --cached (used when the user clicks on a fake commit) we don't add the same filename to the treediff list twice. This also makes getblobdiffline recognize the "* Unmerged path ..." lines we get when we ask for the actual diffs, and makes a tiny optimization in makediffhdr. Signed-off-by: Paul Mackerras <paulus@samba.org>

Paul Mackerras committed Nov 4, 2008 at 21:09 UTC 48a81b7cda1e58d8cc4d9bcadce76bbf1680ab7d
1 file changed +17 -3
gitk
+17 -3
@@ -6854,8 +6854,10 @@ proc gettreediffline {gdtf ids} {
6854 set file [lindex $file 0]
6855 }
6856 set file [encoding convertfrom $file]
6857 - lappend treediff $file
6858 - lappend sublist $file
6857 + if {$file ne [lindex $treediff end]} {
6858 + lappend treediff $file
6859 + lappend sublist $file
6860 + }
6861 }
6862 }
6863 if {$perfile_attrs} {
@@ -6960,7 +6962,7 @@ proc makediffhdr {fname ids} {
6962 if {$i >= 0} {
6963 setinlist difffilestart $i $curdiffstart
6964 }
6963 - set ctext_file_names [lreplace $ctext_file_names end end $fname]
6965 + lset ctext_file_names end $fname
6966 set l [expr {(78 - [string length $fname]) / 2}]
6967 set pad [string range "----------------------------------------" 1 $l]
6968 $ctext insert $curdiffstart "$pad $fname $pad" filesep
@@ -7033,6 +7035,18 @@ proc getblobdiffline {bdf ids} {
7035 }
7036 makediffhdr $fname $ids
7037
7038 + } elseif {![string compare -length 16 "* Unmerged path " $line]} {
7039 + set fname [encoding convertfrom [string range $line 16 end]]
7040 + $ctext insert end "\n"
7041 + set curdiffstart [$ctext index "end - 1c"]
7042 + lappend ctext_file_names $fname
7043 + lappend ctext_file_lines [lindex [split $curdiffstart "."] 0]
7044 + $ctext insert end "$line\n" filesep
7045 + set i [lsearch -exact $treediffs($ids) $fname]
7046 + if {$i >= 0} {
7047 + setinlist difffilestart $i $curdiffstart
7048 + }
7049 +
7050 } elseif {![string compare -length 2 "@@" $line]} {
7051 regexp {^@@+} $line ats
7052 set line [encoding convertfrom $diffencoding $line]