@matheusbsbs / matheus-bagliano / commits / 39acfa3d22
Fork 0

git gui: fix branch name encoding error

After "git checkout -b '漢字'" to create a branch with UTF-8 character in it, "git gui" shows the branch name incorrectly, as it forgets to turn the bytes read from the "git for-each-ref" and read from "HEAD" file into Unicode characters. Signed-off-by: Kazuhiro Kato <kato-k@ksysllc.co.jp> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>

Kazuhiro Kato committed Dec 7, 2019 at 00:29 UTC 39acfa3d224e4a125a3f72ef761ee2cbd24216c2
2 files changed +3
git-gui.sh
+1
@@ -684,6 +684,7 @@ proc load_current_branch {} {
684 global current_branch is_detached
685
686 set fd [open [gitdir HEAD] r]
687 + fconfigure $fd -translation binary -encoding utf-8
688 if {[gets $fd ref] < 1} {
689 set ref {}
690 }
lib/branch.tcl
+2
@@ -8,6 +8,7 @@ proc load_all_heads {} {
8 set rh_len [expr {[string length $rh] + 1}]
9 set all_heads [list]
10 set fd [git_read for-each-ref --format=%(refname) $rh]
11 + fconfigure $fd -translation binary -encoding utf-8
12 while {[gets $fd line] > 0} {
13 if {!$some_heads_tracking || ![is_tracking_branch $line]} {
14 lappend all_heads [string range $line $rh_len end]
@@ -24,6 +25,7 @@ proc load_all_tags {} {
25 --sort=-taggerdate \
26 --format=%(refname) \
27 refs/tags]
28 + fconfigure $fd -translation binary -encoding utf-8
29 while {[gets $fd line] > 0} {
30 if {![regsub ^refs/tags/ $line {} name]} continue
31 lappend all_tags $name