Skip to content

Commit 49d707a

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 d02e784 commit 49d707a

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
@@ -7855,7 +7855,7 @@ proc gettreeline {gtf id} {
78557855
if {[string index $fname 0] eq "\""} {
78567856
set fname [lindex $fname 0]
78577857
}
7858-
set fname [encoding convertfrom $fname]
7858+
set fname [encoding convertfrom utf-8 $fname]
78597859
lappend treefilelist($id) $fname
78607860
}
78617861
if {![eof $gtf]} {
@@ -8117,7 +8117,7 @@ proc gettreediffline {gdtf ids} {
81178117
if {[string index $file 0] eq "\""} {
81188118
set file [lindex $file 0]
81198119
}
8120-
set file [encoding convertfrom $file]
8120+
set file [encoding convertfrom utf-8 $file]
81218121
if {$file ne [lindex $treediff end]} {
81228122
lappend treediff $file
81238123
lappend sublist $file
@@ -8262,7 +8262,7 @@ proc makediffhdr {fname ids} {
82628262
global ctext curdiffstart treediffs diffencoding
82638263
global ctext_file_names jump_to_here targetline diffline
82648264
8265-
set fname [encoding convertfrom $fname]
8265+
set fname [encoding convertfrom utf-8 $fname]
82668266
set diffencoding [get_path_encoding $fname]
82678267
set i [lsearch -exact $treediffs($ids) $fname]
82688268
if {$i >= 0} {
@@ -8324,7 +8324,7 @@ proc parseblobdiffline {ids line} {
83248324
83258325
if {![string compare -length 5 "diff " $line]} {
83268326
if {![regexp {^diff (--cc|--git) } $line m type]} {
8327-
set line [encoding convertfrom $line]
8327+
set line [encoding convertfrom utf-8 $line]
83288328
$ctext insert end "$line\n" hunksep
83298329
continue
83308330
}
@@ -8373,7 +8373,7 @@ proc parseblobdiffline {ids line} {
83738373
makediffhdr $fname $ids
83748374
83758375
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8376-
set fname [encoding convertfrom [string range $line 16 end]]
8376+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
83778377
$ctext insert end "\n"
83788378
set curdiffstart [$ctext index "end - 1c"]
83798379
lappend ctext_file_names $fname
@@ -8426,7 +8426,7 @@ proc parseblobdiffline {ids line} {
84268426
if {[string index $fname 0] eq "\""} {
84278427
set fname [lindex $fname 0]
84288428
}
8429-
set fname [encoding convertfrom $fname]
8429+
set fname [encoding convertfrom utf-8 $fname]
84308430
set i [lsearch -exact $treediffs($ids) $fname]
84318431
if {$i >= 0} {
84328432
setinlist difffilestart $i $curdiffstart
@@ -8445,6 +8445,7 @@ proc parseblobdiffline {ids line} {
84458445
set diffinhdr 0
84468446
return
84478447
}
8448+
set line [encoding convertfrom utf-8 $line]
84488449
$ctext insert end "$line\n" filesep
84498450
84508451
} else {
@@ -12440,7 +12441,7 @@ proc cache_gitattr {attr pathlist} {
1244012441
foreach row [split $rlist "\n"] {
1244112442
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1244212443
if {[string index $path 0] eq "\""} {
12443-
set path [encoding convertfrom [lindex $path 0]]
12444+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1244412445
}
1244512446
set path_attr_cache($attr,$path) $value
1244612447
}

0 commit comments

Comments
 (0)