Skip to content

Commit e5c5ac7

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 7521915 commit e5c5ac7

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
@@ -7847,7 +7847,7 @@ proc gettreeline {gtf id} {
78477847
if {[string index $fname 0] eq "\""} {
78487848
set fname [lindex $fname 0]
78497849
}
7850-
set fname [encoding convertfrom $fname]
7850+
set fname [encoding convertfrom utf-8 $fname]
78517851
lappend treefilelist($id) $fname
78527852
}
78537853
if {![eof $gtf]} {
@@ -8109,7 +8109,7 @@ proc gettreediffline {gdtf ids} {
81098109
if {[string index $file 0] eq "\""} {
81108110
set file [lindex $file 0]
81118111
}
8112-
set file [encoding convertfrom $file]
8112+
set file [encoding convertfrom utf-8 $file]
81138113
if {$file ne [lindex $treediff end]} {
81148114
lappend treediff $file
81158115
lappend sublist $file
@@ -8254,7 +8254,7 @@ proc makediffhdr {fname ids} {
82548254
global ctext curdiffstart treediffs diffencoding
82558255
global ctext_file_names jump_to_here targetline diffline
82568256
8257-
set fname [encoding convertfrom $fname]
8257+
set fname [encoding convertfrom utf-8 $fname]
82588258
set diffencoding [get_path_encoding $fname]
82598259
set i [lsearch -exact $treediffs($ids) $fname]
82608260
if {$i >= 0} {
@@ -8316,7 +8316,7 @@ proc parseblobdiffline {ids line} {
83168316
83178317
if {![string compare -length 5 "diff " $line]} {
83188318
if {![regexp {^diff (--cc|--git) } $line m type]} {
8319-
set line [encoding convertfrom $line]
8319+
set line [encoding convertfrom utf-8 $line]
83208320
$ctext insert end "$line\n" hunksep
83218321
continue
83228322
}
@@ -8365,7 +8365,7 @@ proc parseblobdiffline {ids line} {
83658365
makediffhdr $fname $ids
83668366
83678367
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8368-
set fname [encoding convertfrom [string range $line 16 end]]
8368+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
83698369
$ctext insert end "\n"
83708370
set curdiffstart [$ctext index "end - 1c"]
83718371
lappend ctext_file_names $fname
@@ -8418,7 +8418,7 @@ proc parseblobdiffline {ids line} {
84188418
if {[string index $fname 0] eq "\""} {
84198419
set fname [lindex $fname 0]
84208420
}
8421-
set fname [encoding convertfrom $fname]
8421+
set fname [encoding convertfrom utf-8 $fname]
84228422
set i [lsearch -exact $treediffs($ids) $fname]
84238423
if {$i >= 0} {
84248424
setinlist difffilestart $i $curdiffstart
@@ -8437,6 +8437,7 @@ proc parseblobdiffline {ids line} {
84378437
set diffinhdr 0
84388438
return
84398439
}
8440+
set line [encoding convertfrom utf-8 $line]
84408441
$ctext insert end "$line\n" filesep
84418442
84428443
} else {
@@ -12405,7 +12406,7 @@ proc cache_gitattr {attr pathlist} {
1240512406
foreach row [split $rlist "\n"] {
1240612407
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1240712408
if {[string index $path 0] eq "\""} {
12408-
set path [encoding convertfrom [lindex $path 0]]
12409+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1240912410
}
1241012411
set path_attr_cache($attr,$path) $value
1241112412
}

0 commit comments

Comments
 (0)