# [PATCH] gitk: fix branch name encoding error on gitk

3 messages from 2019-12-07 to 2019-12-15. Participants: 加藤一博, Junio C Hamano, Paul Mackerras.
Thread: https://gitlist.dev/t/52398

## 加藤一博, 2019-12-07 00:32

Subject: [PATCH] gitk: fix branch name encoding error on gitk
Message-ID: <20191207003203.9612-1-kato-k@ksysllc.co.jp>
URL: https://gitlist.dev/e/20191207003203.9612-1-kato-k%40ksysllc.co.jp

```
From: Kazuhiro Kato <kazuhiro.kato@hotmail.co.jp>

After "git checkout -b '漢字'" to create a branch with UTF-8
character in it, "gitk" shows the branch name incorrectly, as it
forgets to turn the bytes read from the "git show-ref" command
into Unicode characters.

Signed-off-by: Kazuhiro Kato <kato-k@ksysllc.co.jp>
---
 gitk | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gitk b/gitk
index abe4805..3f61a5b 100755
--- a/gitk
+++ b/gitk
@@ -1780,11 +1780,15 @@ proc readrefs {} {
     global otherrefids idotherrefs mainhead mainheadid
     global selecthead selectheadid
     global hideremotes
+    global tclencoding
 
     foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
 	unset -nocomplain $v
     }
     set refd [open [list | git show-ref -d] r]
+    if {$tclencoding != {}} {
+	fconfigure $refd -encoding $tclencoding
+    }
     while {[gets $refd line] >= 0} {
 	if {[string index $line 40] ne " "} continue
 	set id [string range $line 0 39]
-- 
2.20.1.windows.1


```

## Junio C Hamano, 2019-12-09 19:19

Subject: Re: [PATCH] gitk: fix branch name encoding error on gitk
Message-ID: <xmqqlfrlux1k.fsf@gitster-ct.c.googlers.com>
URL: https://gitlist.dev/e/xmqqlfrlux1k.fsf%40gitster-ct.c.googlers.com
In-Reply-To: <20191207003203.9612-1-kato-k@ksysllc.co.jp>

```
[jc: pinging the gitk maintainer]

加藤一博 <kato-k@ksysllc.co.jp> writes:

> From: Kazuhiro Kato <kazuhiro.kato@hotmail.co.jp>

Kato-san, do you prefer this address, over ksysllc address?  Either
way, we prefer to see it match the address used on the signed-off-by
line below.

> After "git checkout -b '漢字'" to create a branch with UTF-8
> character in it, "gitk" shows the branch name incorrectly, as it
> forgets to turn the bytes read from the "git show-ref" command
> into Unicode characters.
>
> Signed-off-by: Kazuhiro Kato <kato-k@ksysllc.co.jp>
> ---
>  gitk | 4 ++++
>  1 file changed, 4 insertions(+)

Thanks.

> diff --git a/gitk b/gitk
> index abe4805..3f61a5b 100755
> --- a/gitk
> +++ b/gitk
> @@ -1780,11 +1780,15 @@ proc readrefs {} {
>      global otherrefids idotherrefs mainhead mainheadid
>      global selecthead selectheadid
>      global hideremotes
> +    global tclencoding
>  
>      foreach v {tagids idtags headids idheads otherrefids idotherrefs} {
>  	unset -nocomplain $v
>      }
>      set refd [open [list | git show-ref -d] r]
> +    if {$tclencoding != {}} {
> +	fconfigure $refd -encoding $tclencoding
> +    }
>      while {[gets $refd line] >= 0} {
>  	if {[string index $line 40] ne " "} continue
>  	set id [string range $line 0 39]

```

## Paul Mackerras, 2019-12-15 04:29

Subject: Re: [PATCH] gitk: fix branch name encoding error on gitk
Message-ID: <20191215042931.GB12512@blackberry>
URL: https://gitlist.dev/e/20191215042931.GB12512%40blackberry
In-Reply-To: <20191207003203.9612-1-kato-k@ksysllc.co.jp>

```
On Sat, Dec 07, 2019 at 12:32:25AM +0000, 加藤一博 wrote:
> From: Kazuhiro Kato <kazuhiro.kato@hotmail.co.jp>
> 
> After "git checkout -b '漢字'" to create a branch with UTF-8
> character in it, "gitk" shows the branch name incorrectly, as it
> forgets to turn the bytes read from the "git show-ref" command
> into Unicode characters.
> 
> Signed-off-by: Kazuhiro Kato <kato-k@ksysllc.co.jp>

Thanks, applied.

Paul.

```
