summaryrefslogtreecommitdiff
path: root/git-gui.sh
diff options
context:
space:
mode:
authorKarsten Blees <blees@dcon.de>2015-02-26 09:19:45 (GMT)
committerPat Thoyts <patthoyts@users.sourceforge.net>2016-10-06 08:23:21 (GMT)
commitae75e1e432b40a8de8e131888951a831ecef8915 (patch)
tree87bbfef57090228b022ba06e56fd4b0f6a8bd3e1 /git-gui.sh
parente2039e946e6efa6c220b3cf186671f93e7aec9b9 (diff)
downloadgit-ae75e1e432b40a8de8e131888951a831ecef8915.zip
git-ae75e1e432b40a8de8e131888951a831ecef8915.tar.gz
git-ae75e1e432b40a8de8e131888951a831ecef8915.tar.bz2
git-gui: handle the encoding of Git's output correctly
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: https://github.com/msysgit/git/issues/302 Cloud Chou find the reason of the bug. Thanks-to: Johannes Schindelin <johannes.schindelin@gmx.de> Thanks-to: Pat Thoyts <patthoyts@users.sourceforge.net> Reported-by: Cloud Chou <515312382@qq.com> Original-test-by: Cloud Chou <515312382@qq.com> Signed-off-by: Karsten Blees <blees@dcon.de> Signed-off-by: Cloud Chou <515312382@qq.com> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Pat Thoyts <patthoyts@users.sourceforge.net>
Diffstat (limited to 'git-gui.sh')
-rwxr-xr-xgit-gui.sh29
1 files changed, 4 insertions, 25 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 1f5acc3..5bc21b8 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -534,31 +534,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"
}