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

[IRC/patches] Failed octopus merge does not clean up

From
Thomas Rast <trast@student.ethz.ch>
Date
Sep 15, 2008, 22:48 UTC
Message-ID
<200809160048.31443.trast@student.ethz.ch>
Hi *

James "jammyd" Mulcahy pointed out on IRC that the octopus merge strategy doesn't properly clean up behind itself. To wit:

  git init
  echo initial > foo
  git add foo
  git commit -m initial
  echo a > foo
  git commit -m a foo
  git checkout -b b HEAD^
  echo b > foo
  git commit -m b foo
  git checkout -b c HEAD^
  echo c > foo
  git commit -m c foo
  git checkout master
  git merge b c
The merge says
  Trying simple merge with 5b3e4bb1c2d88d6967fb575729fbfc86df5eaec9
  Simple merge did not work, trying automatic merge.
  Auto-merging foo
  ERROR: Merge conflict in foo
  fatal: merge program failed
  Automated merge did not work.
  Should not be doing an Octopus.
  Merge with strategy octopus failed.
So far so good.  However, 'git status' claims
  #       unmerged:   foo

and indeed the contents of 'foo' are the conflicted merge between 'master' and 'b', yet there is no .git/MERGE_HEAD. This behaviour is identical for 1.5.6 and 1.6.0.2, so it is not caused by the merge rewrite as a builtin. Shouldn't it either really clean up, or really leave the repo in a conflicted merge state? (I'm following up with a patch that turns the above into a test. Octopus doesn't really have many tests, does it?)

On the code path to the "Merge with strategy %s failed" message, builtin-merge.c:1134 runs restore_state() which runs reset_hard(). But (as Miklos pointed out) that cannot actually do 'git reset --hard' because it is possible (though not recommended, see below) to start a merge with a dirty index.

Jakub mentioned that there are only three index stages for a three-way merge, so a conflicted n-way (simultaneous) merge is not really possible.

The merge manpage should warn about merging with uncommitted changes. It recommends 'git rebase --hard' to abort during conflicts, but does not mention that this throws away said changes. I'm following up with a patch for this.

- Thomas
-- 
Thomas Rast
trast@student.ethz.ch
Next: Thomas Rast
Message 1 of 17 in “[IRC/patches] Failed octopus merge does not clean up”
  1. Thomas RastSep 15, 2008
  2. Add test that checks octopus merge cleanupThomas Rast, Sep 15, 2008
  3. Documentation: warn against merging in a dirty treeThomas Rast, Sep 15, 2008
  4. Junio C HamanoSep 15, 2008
  5. Avery PennarunSep 15, 2008
  6. Junio C HamanoSep 16, 2008
  7. Linus TorvaldsSep 18, 2008
  8. Avery PennarunSep 18, 2008
  9. Junio C HamanoSep 19, 2008
  10. Junio C HamanoSep 15, 2008
  11. Thomas RastSep 15, 2008
  12. Junio C HamanoSep 16, 2008
  13. Jakub NarebskiSep 16, 2008
  14. Andreas EricssonSep 17, 2008
  15. Jakub NarebskiSep 17, 2008
  16. Miklos VajnaSep 17, 2008
  17. Andreas EricssonSep 17, 2008

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.