threads / patch / 52398

patchgitk: fix branch name encoding error on gitk

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

## tl;dr

3 messages between Dec 7, 2019 and Dec 15, 2019. Diffs are folded; open one to read it.

replies: 2people: 3as markdown or json

加藤一博· Dec 7, 2019, 00:32 UTC · lore
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(+)
Show changes to gitk +4 −0
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· Dec 9, 2019, 19:19 UTC · re: 加藤一博 · lore

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

[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.

Show 9 quoted lines
> 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.
Show 20 quoted lines
> 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· Dec 15, 2019, 04:29 UTC · re: 加藤一博 · lore

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

On Sat, Dec 07, 2019 at 12:32:25AM +0000, 加藤一博 wrote:
Show 8 quoted lines
> 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.

← back to recent threads