Skip to content

Incorrect cherry-pick conflict message encoding #664

Closed
@yaras

Description

@yaras
  • I was not able to find an open
    or closed issue
    matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? 32-bit or 64-bit? Include the
    output of git version as well.

    Git-2.7.1.2-64-bit.exe

$ git --version
git version 2.7.1.windows.2
  • Which version of Windows are you running? 32-bit or 64-bit?

    Windows 10 Home, 64 bit

  • What options did you set as part of the installation? Or did you choose the
    defaults?

    defaults

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

    MinTTY

  • What commands did you run to trigger this issue? If you can provide a
    Minimal, Complete, and Verifiable example
    this will help us understand the issue.

git init .
echo "test" > test
git add . && git commit -m 'Initial'

git checkout -b development
echo "a" >> test
git add . && git commit -m 'Change on devel (ęółąśłżźćń)'

git checkout master
echo "b" >> test
git add . && git commit -m 'Change on master'

After above steps my repository looks like:

$ git log --graph --oneline --branches --decorate
* d1cd79c (HEAD -> master) Change on master
| * ab514a8 (development) Change on devel (ęółąśłżźćń)
|/
* 698a591 Initial

Then I cherry-pick “Change on devel (…)” which produces expected conflict:

$ git cherry-pick development
error: could not apply ab514a8... Change on devel (ęółąśłżźćń)
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

$ git status
On branch master
You are currently cherry-picking commit ab514a8.
  (fix conflicts and run "git cherry-pick --continue")
  (use "git cherry-pick --abort" to cancel the cherry-pick operation)

Unmerged paths:
  (use "git add <file>..." to mark resolution)

        both modified:   test

no changes added to commit (use "git add" and/or "git commit -a")

and creates a file .git/MERGE_MSG which contains message with valid encoding:

$ cat .git/MERGE_MSG
Change on devel (ęółąśłżźćń)

# Conflicts:
#       test

But, when I run git gui initial commit message gets invalid encoding (which is reflected in GITGUI_MSG file):

$ git gui

$ cat .git/GITGUI_MSG
Change on devel (ęółąśłżźćń)

# Conflicts:
#       test
  • What did you expect to occur after running these commands?

I expect valid encoding in git gui window and in GITGUI_MSG file.

  • What actually happened instead?

    Message in commit prompt in git gui has invalid encoding.

Fix proposal

I think that the problem is in git-gui load_message function and this is my fix proposal:

diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index 0290a45..73c653a 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -1472,7 +1472,7 @@ proc rescan {after {honor_trustmtime 1}} {
                 if {[string match amend* $commit_type]} {
                 } elseif {[load_message GITGUI_MSG utf-8]} {
                 } elseif {[run_prepare_commit_msg_hook]} {
-                } elseif {[load_message MERGE_MSG]} {
+                } elseif {[load_message MERGE_MSG utf-8]} {
                 } elseif {[load_message SQUASH_MSG]} {
                 }
                 $ui_comm edit reset

before I create a pull-request I’d like to consult whether it is a good way of fixing it and whether I should also add utf-8 to loading SQUASH_MSG.

Next week I'm going to test this fix and if it solves the problem I'll create a Pull Request.

I'd like to write some tests, but I have no idea how to simulate run of git gui. Any suggestions?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions