git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Invalid initial git gui message encoding

From
JZjarek z. <yaras6@gmail.com>
Date
Feb 29, 2016, 17:50 UTC
Message-ID
<CABvS4Ohe3fKG6qcDHtryLR3Mokt44m4AM6oP0p3PisvxndO+oA@mail.gmail.com>
Hello.

Working with Git for Windows on git gui I noticed an issue on reading initial message to git gui message prompt after squash or cherry-pick conflict. When system encoding is not set to UTF-8 (and on my Windows it is cp1250) squash/cherry pick conflict message gets invalid encoding.

This issue and test case is more widely described on https://github.com/git-for-windows/git/issues/664 . After I set encoding to UTF-8 using fconfigure, the problem seems to be fixed.

I tried it also on Linux, but I cannot reproduce this problem as its default encoding is utf-8. I verified it using simple tcl script: "puts [encoding system]". On Windows I get:

$ tclsh enc.tcl cp1250

on Linux:

$ tclsh enc.tcl utf-8

It may be not a big issue for Linux, but I think it is worth to have it merged in case of somebody had other encoding than UTF-8. This fix has been already merged into Git for Windows.

As stated in Documentation/SubmittingPatches, this patch is based on git://repo.or.cz/git-gui.git.

BTW. Is there any example of writing regression tests for git-gui?
Signed-off-by: yaras <yaras6@gmail.com>
---
 git-gui.sh | 2 ++
 1 file changed, 2 insertions(+)
diff --git a/git-gui.sh b/git-gui.sh
index 11048c7..1ed5185 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -1616,11 +1616,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 {
--
Message 1 of 1 in “Invalid initial git gui message encoding”
  1. jarek z.Feb 29, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.