Invalid initial git gui message encoding

From: jarek z. <hidden>
Date: 2016-06-15 23:08:23
Subsystem: the rest · Maintainer: Linus Torvalds

Hello.

Working with Git for Windows on git gui I noticed an issue on reading
initial message to git gui message prompt.

Steps to reproduce:

  git init .
  echo 'a' > a && git add . && git commit -m 'added A'
  git checkout -b devel
  echo 'b' > b && git add . && git commit -m 'added B (ęóąśłżźćń)'
  echo 'bbb' >> b && git add . && git commit -m 'changed B (żźćńąśłóę)'
  git checkout master
  git merge --squash devel

after above commands I run git gui where I get initial message with
invalid encoding. I described it more widely on github:
https://github.com/git-for-windows/git/issues/664#issuecomment-187664072.

I prepared a fix on https://github.com/git-for-windows/git/pull/665.
Before I send a patch based on git://repo.or.cz/git-gui.git may I ask
you to review my changes? I also attach them to this message below.
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 1834f00..5771973 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1599,11 +1599,13 @@ proc run_prepare_commit_msg_hook {} {
  if {[file isfile [gitdir MERGE_MSG]]} {
  set pcm_source "merge"
  set fd_mm [open [gitdir MERGE_MSG] r]
+ fconfigure $fd_mm -encoding utf-8
  puts -nonewline $fd_pcm [read $fd_mm]
  close $fd_mm
  } elseif {[file isfile [gitdir SQUASH_MSG]]} {
  set pcm_source "squash"
  set fd_sm [open [gitdir SQUASH_MSG] r]
+ fconfigure $fd_sm -encoding utf-8
  puts -nonewline $fd_pcm [read $fd_sm]
  close $fd_sm
  } else {
---
Yours sincerely,
Jarek Z.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help