Skip to content

Commit 493c22b

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 92afe2d commit 493c22b

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
@@ -7634,7 +7634,7 @@ proc gettreeline {gtf id} {
76347634
if {[string index $fname 0] eq "\""} {
76357635
set fname [lindex $fname 0]
76367636
}
7637-
set fname [encoding convertfrom $fname]
7637+
set fname [encoding convertfrom utf-8 $fname]
76387638
lappend treefilelist($id) $fname
76397639
}
76407640
if {![eof $gtf]} {
@@ -7896,7 +7896,7 @@ proc gettreediffline {gdtf ids} {
78967896
if {[string index $file 0] eq "\""} {
78977897
set file [lindex $file 0]
78987898
}
7899-
set file [encoding convertfrom $file]
7899+
set file [encoding convertfrom utf-8 $file]
79007900
if {$file ne [lindex $treediff end]} {
79017901
lappend treediff $file
79027902
lappend sublist $file
@@ -8041,7 +8041,7 @@ proc makediffhdr {fname ids} {
80418041
global ctext curdiffstart treediffs diffencoding
80428042
global ctext_file_names jump_to_here targetline diffline
80438043

8044-
set fname [encoding convertfrom $fname]
8044+
set fname [encoding convertfrom utf-8 $fname]
80458045
set diffencoding [get_path_encoding $fname]
80468046
set i [lsearch -exact $treediffs($ids) $fname]
80478047
if {$i >= 0} {
@@ -8103,7 +8103,7 @@ proc parseblobdiffline {ids line} {
81038103

81048104
if {![string compare -length 5 "diff " $line]} {
81058105
if {![regexp {^diff (--cc|--git) } $line m type]} {
8106-
set line [encoding convertfrom $line]
8106+
set line [encoding convertfrom utf-8 $line]
81078107
$ctext insert end "$line\n" hunksep
81088108
continue
81098109
}
@@ -8150,7 +8150,7 @@ proc parseblobdiffline {ids line} {
81508150
makediffhdr $fname $ids
81518151

81528152
} elseif {![string compare -length 16 "* Unmerged path " $line]} {
8153-
set fname [encoding convertfrom [string range $line 16 end]]
8153+
set fname [encoding convertfrom utf-8 [string range $line 16 end]]
81548154
$ctext insert end "\n"
81558155
set curdiffstart [$ctext index "end - 1c"]
81568156
lappend ctext_file_names $fname
@@ -8205,7 +8205,7 @@ proc parseblobdiffline {ids line} {
82058205
if {[string index $fname 0] eq "\""} {
82068206
set fname [lindex $fname 0]
82078207
}
8208-
set fname [encoding convertfrom $fname]
8208+
set fname [encoding convertfrom utf-8 $fname]
82098209
set i [lsearch -exact $treediffs($ids) $fname]
82108210
if {$i >= 0} {
82118211
setinlist difffilestart $i $curdiffstart
@@ -8224,6 +8224,7 @@ proc parseblobdiffline {ids line} {
82248224
set diffinhdr 0
82258225
return
82268226
}
8227+
set line [encoding convertfrom utf-8 $line]
82278228
$ctext insert end "$line\n" filesep
82288229

82298230
} else {
@@ -12161,7 +12162,7 @@ proc cache_gitattr {attr pathlist} {
1216112162
foreach row [split $rlist "\n"] {
1216212163
if {[regexp "(.*): $attr: (.*)" $row m path value]} {
1216312164
if {[string index $path 0] eq "\""} {
12164-
set path [encoding convertfrom [lindex $path 0]]
12165+
set path [encoding convertfrom utf-8 [lindex $path 0]]
1216512166
}
1216612167
set path_attr_cache($attr,$path) $value
1216712168
}

0 commit comments

Comments
 (0)