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

Question about git-merge-stupid

From
Miklos Vajna <vmiklos@frugalware.org>
Date
Jul 3, 2008, 12:33 UTC
Message-ID
<20080703123314.GS4729@genesis.frugalware.org>
Hi,

I'm trying to understand what is the difference between different merge strategies. git-merge-stupid is something I failed to understand from the git history/code/documentation, so I'm asking here.

1) From git history:

It seems git-merge-stupid was created by 2276aa6 when Junio renamed -resolve to -stupid and let -resolve use read-tree. Actually

        git show 2276aa6:git-merge-stupid.sh
says -stupid uses read-tree as well.
2) From code:

It seems -stupid is better than -resolve when there are multiple bases. -resolve just passes all bases to read-tree, while -stupid tries to find the best one. It does it by counting unmerged entries and the less one is a better.

Here is what I tried:
A - B - C
      X   \
  \ D - E - F
(Where 'A' adds 'a.c' while the contents 'a', etc.)

$ git reset --hard e $ git merge -s resolve c Trying simple merge. Merge made by resolve.

So it seems resolve does not completely fail if there are multiple bases, either.

I would like to write a testcase that ensures git-merge-stupid really picks the best base, but I don't know exactly in what situation can the number of unmerged entires differ.

3) From documentation:

Actually -stupid is missing from Documentation/merge-strategies.txt. I plan to send a patch to add it, once I understnad what it does. :-)

Thanks.

[ Writing to Linus as suggested by Dscho, adding Junio to CC as - according to git log - both strategy created by him. ]

Next: Linus Torvalds
Message 1 of 7 in “Question about git-merge-stupid”
  1. Miklos VajnaJul 3, 2008
  2. Linus TorvaldsJul 3, 2008
  3. Remove 'stupid' merge strategy.Miklos Vajna, Jul 3, 2008
  4. Junio C HamanoJul 3, 2008
  5. Miklos VajnaJul 4, 2008
  6. Move 'stupid' merge strategy to contrib.Miklos Vajna, Jul 5, 2008
  7. Move 'stupid' merge strategy to contrib.Miklos Vajna, Jul 5, 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.