Skip to content

Commit 05ca44a

Browse files
kbleesdscho
authored andcommitted
gitk: Unicode file name support
Assumes file names in git tree objects are UTF-8 encoded. On most unix systems, the system encoding (and thus the TCL system encoding) will be UTF-8, so file names will be displayed correctly. On Windows, it is impossible to set the system encoding to UTF-8. Changing the TCL system encoding (via 'encoding system ...', e.g. in the startup code) is explicitly discouraged by the TCL docs. Change gitk functions dealing with file names to always convert from and to UTF-8. Signed-off-by: Karsten Blees <[email protected]> Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 787bfe4 commit 05ca44a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

gitk-git/gitk

+8-7
Original file line numberDiff line numberDiff line change
@@ -7692,7 +7692,7 @@ proc gettreeline {gtf id} {
76927692
if {[string index $fname 0] eq "\""} {
76937693
set fname [lindex $fname 0]
76947694
}
7695-
set fname [encoding convertfrom $fname]
7695+
set fname [encoding convertfrom utf-8 $fname]
76967696
lappend treefilelist($id) $fname
76977697
}
76987698
if {![eof $gtf]} {
@@ -7954,7 +7954,7 @@ proc gettreediffline {gdtf ids} {
79547954
if {[string index $file 0] eq "\""} {
79557955
set file [lindex $file 0]
79567956
}
7957-
set file [encoding convertfrom $file]
7957+
set file [encoding convertfrom utf-8 $file]
79587958
if {$file ne [lindex $treediff end]} {
79597959
lappend treediff $file
79607960
lappend sublist $file
@@ -8099,7 +8099,7 @@ proc makediffhdr {fname ids} {
80998099
global ctext curdiffstart treediffs diffencoding
81008100
global ctext_file_names jump_to_here targetline diffline
81018101

8102-
set fname [encoding convertfrom $fname]
8102+
set fname [encoding convertfrom utf-8 $fname]
81038103
set diffencoding [get_path_encoding $fname]
81048104
set i [lsearch -exact $treediffs($ids) $fname]
81058105
if {$i >= 0} {
@@ -8161,7 +8161,7 @@ proc parseblobdiffline {ids line} {
81618161

81628162
if {![string compare -length 5 "diff " $line]} {
81638163
if {![regexp {^diff (--cc|--git) } $line m type]} {
8164-
set line [encoding convertfrom $line]
8164+
set line [encoding convertfrom utf-8 $line]
81658165
$ctext insert end "$line\n" hunksep
81668166
continue
81678167
}
@@ -8210,7 +8210,7 @@ proc parseblobdiffline {ids line} {
82108210
makediffhdr $fname $ids
82118211

82128212
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8213-
set fname [encoding convertfrom [string range $line 16 end]]
8213+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
82148214
$ctext insert end "\n"
82158215
set curdiffstart [$ctext index "end - 1c"]
82168216
lappend ctext_file_names $fname
@@ -8263,7 +8263,7 @@ proc parseblobdiffline {ids line} {
82638263
if {[string index $fname 0] eq "\""} {
82648264
set fname [lindex $fname 0]
82658265
}
8266-
set fname [encoding convertfrom $fname]
8266+
set fname [encoding convertfrom utf-8 $fname]
82678267
set i [lsearch -exact $treediffs($ids) $fname]
82688268
if {$i >= 0} {
82698269
setinlist difffilestart $i $curdiffstart
@@ -8282,6 +8282,7 @@ proc parseblobdiffline {ids line} {
82828282
set diffinhdr 0
82838283
return
82848284
}
8285+
set line [encoding convertfrom utf-8 $line]
82858286
$ctext insert end "$line\n" filesep
82868287

82878288
} else {
@@ -12244,7 +12245,7 @@ proc cache_gitattr {attr pathlist} {
1224412245
foreach row [split $rlist "\n"] {
1224512246
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1224612247
if {[string index $path 0] eq "\""} {
12247-
set path [encoding convertfrom [lindex $path 0]]
12248+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1224812249
}
1224912250
set path_attr_cache($attr,$path) $value
1225012251
}

0 commit comments

Comments
 (0)