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 <spearce@spearce.org>
This commit is contained in:
Shawn O. Pearce
2007-01-23 04:07:18 -05:00
parent 0565246a7c
commit 51a989ba5a

View File

@ -410,9 +410,9 @@ proc rescan_stage2 {fd after} {
set fd_df [open "| git diff-files -z" r] set fd_df [open "| git diff-files -z" r]
set fd_lo [open $ls_others r] set fd_lo [open $ls_others r]
fconfigure $fd_di -blocking 0 -translation binary fconfigure $fd_di -blocking 0 -translation binary -encoding binary
fconfigure $fd_df -blocking 0 -translation binary fconfigure $fd_df -blocking 0 -translation binary -encoding binary
fconfigure $fd_lo -blocking 0 -translation binary fconfigure $fd_lo -blocking 0 -translation binary -encoding binary
fileevent $fd_di readable [list read_diff_index $fd_di $after] fileevent $fd_di readable [list read_diff_index $fd_di $after]
fileevent $fd_df readable [list read_diff_files $fd_df $after] fileevent $fd_df readable [list read_diff_files $fd_df $after]
fileevent $fd_lo readable [list read_ls_others $fd_lo $after] fileevent $fd_lo readable [list read_ls_others $fd_lo $after]
@ -450,8 +450,9 @@ proc read_diff_index {fd after} {
incr c incr c
set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }] set i [split [string range $buf_rdi $c [expr {$z1 - 2}]] { }]
set p [string range $buf_rdi $z1 [expr {$z2 - 1}]]
merge_state \ merge_state \
[string range $buf_rdi $z1 [expr {$z2 - 1}]] \ [encoding convertfrom $p] \
[lindex $i 4]? \ [lindex $i 4]? \
[list [lindex $i 0] [lindex $i 2]] \ [list [lindex $i 0] [lindex $i 2]] \
[list] [list]
@ -482,8 +483,9 @@ proc read_diff_files {fd after} {
incr c incr c
set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }] set i [split [string range $buf_rdf $c [expr {$z1 - 2}]] { }]
set p [string range $buf_rdf $z1 [expr {$z2 - 1}]]
merge_state \ merge_state \
[string range $buf_rdf $z1 [expr {$z2 - 1}]] \ [encoding convertfrom $p] \
?[lindex $i 4] \ ?[lindex $i 4] \
[list] \ [list] \
[list [lindex $i 0] [lindex $i 2]] [list [lindex $i 0] [lindex $i 2]]
@ -506,7 +508,7 @@ proc read_ls_others {fd after} {
set pck [split $buf_rlo "\0"] set pck [split $buf_rlo "\0"]
set buf_rlo [lindex $pck end] set buf_rlo [lindex $pck end]
foreach p [lrange $pck 0 end-1] { foreach p [lrange $pck 0 end-1] {
merge_state $p ?O merge_state [encoding convertfrom $p] ?O
} }
rescan_done $fd buf_rlo $after rescan_done $fd buf_rlo $after
} }
@ -1459,6 +1461,7 @@ proc update_indexinfo {msg pathList after} {
-blocking 0 \ -blocking 0 \
-buffering full \ -buffering full \
-buffersize 512 \ -buffersize 512 \
-encoding binary \
-translation binary -translation binary
fileevent $fd writable [list \ fileevent $fd writable [list \
write_update_indexinfo \ write_update_indexinfo \
@ -1499,7 +1502,7 @@ proc write_update_indexinfo {fd pathList totalCnt batch msg after} {
set info [lindex $s 2] set info [lindex $s 2]
if {$info eq {}} continue if {$info eq {}} continue
puts -nonewline $fd "$info\t$path\0" puts -nonewline $fd "$info\t[encoding convertto $path]\0"
display_file $path $new display_file $path $new
} }
@ -1531,6 +1534,7 @@ proc update_index {msg pathList after} {
-blocking 0 \ -blocking 0 \
-buffering full \ -buffering full \
-buffersize 512 \ -buffersize 512 \
-encoding binary \
-translation binary -translation binary
fileevent $fd writable [list \ fileevent $fd writable [list \
write_update_index \ write_update_index \
@ -1575,7 +1579,7 @@ proc write_update_index {fd pathList totalCnt batch msg after} {
?M {set new M_} ?M {set new M_}
?? {continue} ?? {continue}
} }
puts -nonewline $fd "$path\0" puts -nonewline $fd "[encoding convertto $path]\0"
display_file $path $new display_file $path $new
} }
@ -1613,6 +1617,7 @@ proc checkout_index {msg pathList after} {
-blocking 0 \ -blocking 0 \
-buffering full \ -buffering full \
-buffersize 512 \ -buffersize 512 \
-encoding binary \
-translation binary -translation binary
fileevent $fd writable [list \ fileevent $fd writable [list \
write_checkout_index \ write_checkout_index \
@ -1645,7 +1650,7 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
U? {continue} U? {continue}
?M - ?M -
?D { ?D {
puts -nonewline $fd "$path\0" puts -nonewline $fd "[encoding convertto $path]\0"
display_file $path ?_ display_file $path ?_
} }
} }