Skip to content

Commit 39acfa3

Browse files
kkato233prati0100
authored andcommitted
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 <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]>
1 parent 2763530 commit 39acfa3

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

git-gui.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ proc load_current_branch {} {
684684
global current_branch is_detached
685685
686686
set fd [open [gitdir HEAD] r]
687+
fconfigure $fd -translation binary -encoding utf-8
687688
if {[gets $fd ref] < 1} {
688689
set ref {}
689690
}

lib/branch.tcl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ proc load_all_heads {} {
88
set rh_len [expr {[string length $rh] + 1}]
99
set all_heads [list]
1010
set fd [git_read for-each-ref --format=%(refname) $rh]
11+
fconfigure $fd -translation binary -encoding utf-8
1112
while {[gets $fd line] > 0} {
1213
if {!$some_heads_tracking || ![is_tracking_branch $line]} {
1314
lappend all_heads [string range $line $rh_len end]
@@ -24,6 +25,7 @@ proc load_all_tags {} {
2425
--sort=-taggerdate \
2526
--format=%(refname) \
2627
refs/tags]
28+
fconfigure $fd -translation binary -encoding utf-8
2729
while {[gets $fd line] > 0} {
2830
if {![regsub ^refs/tags/ $line {} name]} continue
2931
lappend all_tags $name

0 commit comments

Comments
 (0)