Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
git-gui:handle the encoding of Git's output correctly
Browse files Browse the repository at this point in the history
if we use 'eval exec $opt $cmdp $args' to execute git command,
tcl engine will convert the output of the git comand with the rule
system default code page to unicode.
But cp936 -> unicode conversion implicitly done by exec is not reversible.
So we have to use git_read instead.

Bug report and an original reproducer by Cloud Chou:
#302

Karsten Blees writes this code patch.
Cloud Chou find the reason of the bug.

Thanks-to: dscho
Thanks-to: patthoyts
Signed-off-by: Karsten Blees <[email protected]>
Original-test-by: Cloud Chou <[email protected]>
Signed-off-by: Cloud Chou <[email protected]>
  • Loading branch information
kblees authored and cloudchou committed Mar 7, 2015
1 parent c47d6ec commit 7020038
Showing 1 changed file with 4 additions and 25 deletions.
29 changes: 4 additions & 25 deletions git-gui/git-gui.sh
Original file line number Diff line number Diff line change
Expand Up @@ -526,31 +526,10 @@ proc _lappend_nice {cmd_var} {
}
proc git {args} {
set opt [list]
while {1} {
switch -- [lindex $args 0] {
--nice {
_lappend_nice opt
}
default {
break
}
}
set args [lrange $args 1 end]
}
set cmdp [_git_cmd [lindex $args 0]]
set args [lrange $args 1 end]
_trace_exec [concat $opt $cmdp $args]
set result [eval exec $opt $cmdp $args]
if {[encoding system] != "utf-8"} {
set result [encoding convertfrom utf-8 [encoding convertto $result]]
}
set fd [eval [list git_read] $args]
fconfigure $fd -translation binary -encoding utf-8
set result [string trimright [read $fd] "\n"]
close $fd
if {$::_trace} {
puts stderr "< $result"
}
Expand Down

0 comments on commit 7020038

Please sign in to comment.