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

git rebase -i / git-gui bug

From
BHBernt Hansen <bernt@alumni.uwaterloo.ca>
Date
Dec 20, 2007, 00:35 UTC
Message-ID
<87ve6ub3u7.fsf@gollum.intra.norang.ca>
Thanks for a great tool I use everyday!

I'm using the tip of master for my regular day job with git-gui to write the commit messages. I've run into a little glitch with git rebase -i and git-gui.

$ git --version git version 1.5.4.rc0.73.gce85b

I haven't been able to automate the process of reproducing this but the steps are fairly simple.

To show the problem you can create a test repository using the following script:

--- t1.sh --- #!/bin/sh cd /tmp mkdir t1 cd t1 git init

for F in f1 f2 f3 f4 f5 f6 f7 f8 f9 f10; do
  echo $F >$F
  git add $F
  echo -n -e "Commit for $F\n\nThis is line one\nThis is line two" >/tmp/commitmsg.txt 
  git commit -F /tmp/commitmsg.txt
done
-------------
Now cd /tmp/t1 and do the following:
$ git rebase -i HEAD~9
Change all lines with 'pick' to 'edit'

For each of the 10 commits use git-gui to select 'Amend Last Commit' and just hit the [Commit] button (you can change the text if you want but it's not necessary to show the problem)

$ git rebase --continue after each commit and repeat until the rebase is complete.

Now if you try to squash these commits the edit buffer commit text is a little mangled.

$ git rebase -i HEAD~9

Change all but the first pick line to 'squash' and I get the following text in the commit message edit window:

----[ /tmp/t1/.git/COMMIT_EDITMSG ]---- # This is a combination of 3 commits. # The first commit's message is:

Commit for f2

This is line one This is line two # This is the 2nd commit message:

Commit for f3

This is line one This is line two# This is the 3rd commit message:

Commit for f4

This is line one This is line two# This is the 3rd commit message:

Commit for f5

This is line one This is line two# This is the 3rd commit message:

Commit for f6

This is line one This is line two# This is the 3rd commit message:

Commit for f7

This is line one This is line two# This is the 3rd commit message:

Commit for f8

This is line one This is line two# This is the 3rd commit message:

Commit for f9

This is line one This is line two# This is the 3rd commit message:

Commit for f10

This is line one This is line two

# Please enter the commit message for your changes. # (Comment lines starting with '#' will not be included) # Not currently on any branch. # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # new file: f10 # new file: f2 # new file: f3 # new file: f4 # new file: f5 # new file: f6 # new file: f7 # new file: f8 # new file: f9 # ---------------------------------------

Notice after the 3rd commit the '# This is the 3rd commit message:' is appended to the last line of the previous commit message and the counter seems to be stuck on 3.

---

When I run into this during work I fix up the commit text by adding newlines before the '# This is the 3rd commit message' and it works fine.

This might be the lack of a newline after the last line in the commit edit message when git-gui creates the commit -- maybe.

If I use git --amend instead of git-gui to update the commits on the above test repository it works correctly.

I'm posting this because someone else can probably fix this faster than me (I've never looked at the git source code). I'll post a patch when I figure it out if nobody else beats me to it.

Regards, Bernt

Next: Bernt Hansen
Message 1 of 28 in “git rebase -i / git-gui bug”
  1. Bernt HansenDec 20, 2007
  2. Bernt HansenDec 20, 2007
  3. Reallow git-rebase --interactive --continue if commit is unnecessaryShawn O. Pearce, Dec 20, 2007
  4. Junio C HamanoDec 20, 2007
  5. Shawn O. PearceDec 20, 2007
  6. Junio C HamanoDec 20, 2007
  7. Junio C HamanoDec 26, 2007
  8. Johannes SchindelinDec 29, 2007
  9. Matthieu MoyDec 20, 2007
  10. Force new line at end of commit messageBernt Hansen, Dec 24, 2007
  11. Johannes SchindelinDec 24, 2007
  12. Shawn O. PearceDec 25, 2007
  13. Junio C HamanoDec 25, 2007
  14. Bernt HansenDec 26, 2007
  15. Shawn O. PearceDec 27, 2007
  16. git-gui: Make commit log messages end with a newlineBernt Hansen, Dec 28, 2007
  17. Junio C HamanoDec 26, 2007
  18. Johannes SchindelinDec 29, 2007
  19. Junio C HamanoDec 30, 2007
  20. Johannes SchindelinDec 30, 2007
  21. Junio C HamanoDec 30, 2007
  22. Johannes SchindelinDec 30, 2007
  23. Junio C HamanoDec 30, 2007
  24. しらいしななこDec 30, 2007
  25. Junio C HamanoDec 30, 2007
  26. Junio C HamanoDec 30, 2007
  27. Johannes SchindelinDec 30, 2007
  28. Shawn O. PearceDec 25, 2007

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.