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

Re: commit following rebase has unexpected commit message

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Aug 5, 2021, 10:02 UTC
Message-ID
<d47652d2-7353-f4ff-5549-ef1c2bc6a381@gmail.com>
In-Reply-To
<CAMsiUYDD3jTyP-pK7PiydECkUAJspzosc8mWNSFpcLru70zXbQ@mail.gmail.com>
Hi Victor
On 04/08/2021 15:19, Victor Gambier wrote:
 > Thank you for filling out a Git bug report!
 > Please answer the following questions to help us understand your issue.
 >
 > What did you do before the bug happened? (Steps to reproduce your issue)
 >
 > git switch -c first
 > git switch -c second
 > [modify a file]
 > git commit -am "foo"
 > git switch first
 > [modify the same file in a conflicting way]
 > git commit -am "bar"
 > git rebase second
 > git restore --staged .
 > git restore .
 > git rebase --continue
 > [modify any file - can be the same file again]
 > git commit -a
 >
 > What did you expect to happen? (Expected behavior)
 >
 > The text editor should pop up and the first line should be blank (no 
default commit message).
 >
 > What happened instead? (Actual behavior)
 >
 > The text editor pops up, and the first four lines of the default 
commit message seem to pertain to the rebase:
 >
 > 	bar
 >
 > 	# Conflicts:
 > 	#	frontend/src/styling/rounds.ts
 >
 > Even though the contents of the commit correctly pertain to the very 
last changes and are unrelated to the rebase.

Thanks for the detailed report, I think the problem is that when rebase stops for the user to resolve conflicts it writes .git/MERGE_MSG which is removed when the conflict resolution is committed or by 'git reset' if the user skips the commit. In this case the commit is effectively skipped but the file is not removed and so seeds the editor when you next make a commit. I'll try and put a patch together next week.

Best Wishes
Phillip
 > What's different between what you expected and what actually happened?
 >
 > The default commit message.
 >
 > Anything else you want to add:
 >
 > A second anomaly is that if you replace the last command with git 
commit -a --no-edit, the two lines starting with '#' are NOT ignored and 
will be present in the final commit message.
 >
 > Please review the rest of the bug report below.
 > You can delete any lines you don't wish to share.
 >
 >
 > [System Info]
 > git version:
 > git version 2.30.0.windows.2
 > cpu: x86_64
 > built from commit: f8cbc844b81bf6b9e72178bbe891a86c8bf5e9e7
 > sizeof-long: 4
 > sizeof-size_t: 8
 > shell-path: /bin/sh
 > uname: Windows 10.0 18363
 > compiler info: gnuc: 10.2
 > libc info: no libc information available
 > $SHELL (typically, interactive shell): C:\Program 
Files\Git\usr\bin\bash.exe
 >
 >
 > [Enabled Hooks]
Previous: Victor Gambier
Message 2 of 2 in “commit following rebase has unexpected commit message”
  1. Victor GambierAug 4, 2021
  2. Phillip WoodAug 5, 2021

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.