Skip to content

Commit 1619c52

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 8f45006 commit 1619c52

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

gitk-git/gitk

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7689,7 +7689,7 @@ proc gettreeline {gtf id} {
76897689
if {[string index $fname 0] eq "\""} {
76907690
set fname [lindex $fname 0]
76917691
}
7692-
set fname [encoding convertfrom $fname]
7692+
set fname [encoding convertfrom utf-8 $fname]
76937693
lappend treefilelist($id) $fname
76947694
}
76957695
if {![eof $gtf]} {
@@ -7951,7 +7951,7 @@ proc gettreediffline {gdtf ids} {
79517951
if {[string index $file 0] eq "\""} {
79527952
set file [lindex $file 0]
79537953
}
7954-
set file [encoding convertfrom $file]
7954+
set file [encoding convertfrom utf-8 $file]
79557955
if {$file ne [lindex $treediff end]} {
79567956
lappend treediff $file
79577957
lappend sublist $file
@@ -8096,7 +8096,7 @@ proc makediffhdr {fname ids} {
80968096
global ctext curdiffstart treediffs diffencoding
80978097
global ctext_file_names jump_to_here targetline diffline
80988098

8099-
set fname [encoding convertfrom $fname]
8099+
set fname [encoding convertfrom utf-8 $fname]
81008100
set diffencoding [get_path_encoding $fname]
81018101
set i [lsearch -exact $treediffs($ids) $fname]
81028102
if {$i >= 0} {
@@ -8158,7 +8158,7 @@ proc parseblobdiffline {ids line} {
81588158

81598159
if {![string compare -length 5 "diff " $line]} {
81608160
if {![regexp {^diff (--cc|--git) } $line m type]} {
8161-
set line [encoding convertfrom $line]
8161+
set line [encoding convertfrom utf-8 $line]
81628162
$ctext insert end "$line\n" hunksep
81638163
continue
81648164
}
@@ -8207,7 +8207,7 @@ proc parseblobdiffline {ids line} {
82078207
makediffhdr $fname $ids
82088208

82098209
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8210-
set fname [encoding convertfrom [string range $line 16 end]]
8210+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
82118211
$ctext insert end "\n"
82128212
set curdiffstart [$ctext index "end - 1c"]
82138213
lappend ctext_file_names $fname
@@ -8260,7 +8260,7 @@ proc parseblobdiffline {ids line} {
82608260
if {[string index $fname 0] eq "\""} {
82618261
set fname [lindex $fname 0]
82628262
}
8263-
set fname [encoding convertfrom $fname]
8263+
set fname [encoding convertfrom utf-8 $fname]
82648264
set i [lsearch -exact $treediffs($ids) $fname]
82658265
if {$i >= 0} {
82668266
setinlist difffilestart $i $curdiffstart
@@ -8279,6 +8279,7 @@ proc parseblobdiffline {ids line} {
82798279
set diffinhdr 0
82808280
return
82818281
}
8282+
set line [encoding convertfrom utf-8 $line]
82828283
$ctext insert end "$line\n" filesep
82838284

82848285
} else {
@@ -12241,7 +12242,7 @@ proc cache_gitattr {attr pathlist} {
1224112242
foreach row [split $rlist "\n"] {
1224212243
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1224312244
if {[string index $path 0] eq "\""} {
12244-
set path [encoding convertfrom [lindex $path 0]]
12245+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1224512246
}
1224612247
set path_attr_cache($attr,$path) $value
1224712248
}

0 commit comments

Comments
 (0)