Skip to content

Commit 51a989b

Browse files
committed
git-gui: Honor system encoding for filenames.
Since git operates on filenames using the operating system encoding any data we are receiving from it by way of a pipe, or sending to it by way of a pipe must be formatted in that encoding. This should be the same as the Tcl system encoding, as its the encoding that applications should be using to converse with the operating system. Sadly this does not fix the gitweb/test file in git.git on Macs; that's due to something really broken happening in the filesystem. Signed-off-by: Shawn O. Pearce <[email protected]>
1 parent 0565246 commit 51a989b

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

git-gui.sh

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -410,9 +410,9 @@ proc rescan_stage2 {fd after} {
410410
set fd_df [open "| git diff-files -z" r]
411411
set fd_lo [open $ls_others r]
412412

413-
fconfigure $fd_di -blocking 0 -translation binary
414-
fconfigure $fd_df -blocking 0 -translation binary
415-
fconfigure $fd_lo -blocking 0 -translation binary
413+
fconfigure $fd_di -blocking 0 -translation binary -encoding binary
414+
fconfigure $fd_df -blocking 0 -translation binary -encoding binary
415+
fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
416416
fileevent $fd_di readable [list read_diff_index $fd_di $after]
417417
fileevent $fd_df readable [list read_diff_files $fd_df $after]
418418
fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
@@ -450,8 +450,9 @@ proc read_diff_index {fd after} {
450450

451451
incr c
452452
set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
453+
set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
453454
merge_state \
454-
[string range $buf_rdi $z1 [expr {$z2 - 1}]] \
455+
[encoding convertfrom $p] \
455456
[lindex $i 4]? \
456457
[list [lindex $i 0] [lindex $i 2]] \
457458
[list]
@@ -482,8 +483,9 @@ proc read_diff_files {fd after} {
482483

483484
incr c
484485
set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
486+
set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
485487
merge_state \
486-
[string range $buf_rdf $z1 [expr {$z2 - 1}]] \
488+
[encoding convertfrom $p] \
487489
?[lindex $i 4] \
488490
[list] \
489491
[list [lindex $i 0] [lindex $i 2]]
@@ -506,7 +508,7 @@ proc read_ls_others {fd after} {
506508
set pck [split $buf_rlo "\0"]
507509
set buf_rlo [lindex $pck end]
508510
foreach p [lrange $pck 0 end-1] {
509-
merge_state $p ?O
511+
merge_state [encoding convertfrom $p] ?O
510512
}
511513
rescan_done $fd buf_rlo $after
512514
}
@@ -1459,6 +1461,7 @@ proc update_indexinfo {msg pathList after} {
14591461
-blocking 0 \
14601462
-buffering full \
14611463
-buffersize 512 \
1464+
-encoding binary \
14621465
-translation binary
14631466
fileevent $fd writable [list \
14641467
write_update_indexinfo \
@@ -1499,7 +1502,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
14991502
set info [lindex $s 2]
15001503
if {$info eq {}} continue
15011504

1502-
puts -nonewline $fd "$info\t$path\0"
1505+
puts -nonewline $fd "$info\t[encoding convertto $path]\0"
15031506
display_file $path $new
15041507
}
15051508

@@ -1531,6 +1534,7 @@ proc update_index {msg pathList after} {
15311534
-blocking 0 \
15321535
-buffering full \
15331536
-buffersize 512 \
1537+
-encoding binary \
15341538
-translation binary
15351539
fileevent $fd writable [list \
15361540
write_update_index \
@@ -1575,7 +1579,7 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
15751579
?M {set new M_}
15761580
?? {continue}
15771581
}
1578-
puts -nonewline $fd "$path\0"
1582+
puts -nonewline $fd "[encoding convertto $path]\0"
15791583
display_file $path $new
15801584
}
15811585

@@ -1613,6 +1617,7 @@ proc checkout_index {msg pathList after} {
16131617
-blocking 0 \
16141618
-buffering full \
16151619
-buffersize 512 \
1620+
-encoding binary \
16161621
-translation binary
16171622
fileevent $fd writable [list \
16181623
write_checkout_index \
@@ -1645,7 +1650,7 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
16451650
U? {continue}
16461651
?M -
16471652
?D {
1648-
puts -nonewline $fd "$path\0"
1653+
puts -nonewline $fd "[encoding convertto $path]\0"
16491654
display_file $path ?_
16501655
}
16511656
}

0 commit comments

Comments
 (0)