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

Commit 7020038

Browse files
kbleescloudchou
authored andcommitted
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: #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]>
1 parent c47d6ec commit 7020038

File tree

1 file changed

+4
-25
lines changed

1 file changed

+4
-25
lines changed

Diff for: git-gui/git-gui.sh

+4-25
Original file line numberDiff line numberDiff line change
@@ -526,31 +526,10 @@ proc _lappend_nice {cmd_var} {
526526
}
527527
528528
proc git {args} {
529-
set opt [list]
530-
531-
while {1} {
532-
switch -- [lindex $args 0] {
533-
--nice {
534-
_lappend_nice opt
535-
}
536-
537-
default {
538-
break
539-
}
540-
541-
}
542-
543-
set args [lrange $args 1 end]
544-
}
545-
546-
set cmdp [_git_cmd [lindex $args 0]]
547-
set args [lrange $args 1 end]
548-
549-
_trace_exec [concat $opt $cmdp $args]
550-
set result [eval exec $opt $cmdp $args]
551-
if {[encoding system] != "utf-8"} {
552-
set result [encoding convertfrom utf-8 [encoding convertto $result]]
553-
}
529+
set fd [eval [list git_read] $args]
530+
fconfigure $fd -translation binary -encoding utf-8
531+
set result [string trimright [read $fd] "\n"]
532+
close $fd
554533
if {$::_trace} {
555534
puts stderr "< $result"
556535
}

0 commit comments

Comments
 (0)