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

Re: Potential bug with octopus merges and symlinks

From
Martin von Zweigbergk <martinvonz@gmail.com>
Date
Dec 6, 2021, 16:53 UTC
Message-ID
<CANiSa6jVp5EV73NxchFhHfZxxetdybhZ6r2qXE8O22e8rgpgVg@mail.gmail.com>
In-Reply-To
<20211202030458.GA48278@newk>
On Sat, Dec 4, 2021 at 5:20 AM Michael McClimon <michael@mcclimon.org> wrote:
Show 34 quoted lines
>
> There is a minimal reproducer available at
> https://github.com/mmcclimon/git-merge-problem-demo. Fetch all the branches
> there. The main branch contains a directory (dir1) with a single file
> (file.txt), plus a symlink (dir2), which links to dir1. branch1 replaces this
> symlink with a copy of the files that were linked to. (This was accomplished
> with: rm dir2; cp -r dir1 dir2.) branch2 and branch3 do not touch this
> directory at all.
>
> Merging these three branches fails:
>
> $ git merge branch1 branch2 branch3
> Fast-forwarding to: branch1
> Trying simple merge with branch2
> Simple merge did not work, trying automatic merge.
> Trying simple merge with branch3
> error: Entry 'dir2/file.txt' not uptodate. Cannot merge.
> Merge with strategy octopus failed.
>
> The order here matters! Here is every permutation (1 here is the symlink
> change) to git merge; only the first two fail, all the others work.
>
> 1 2 3   FAIL
> 1 3 2   FAIL
> 2 1 3   PASS
> 2 3 1   PASS
> 3 1 2   PASS
> 3 2 1   PASS
> 1 2     PASS
> 2 1     PASS
> 2 3     PASS
> 3 2     PASS
> 1 3     PASS
> 3 1     PASS

I'm not a Git contributor (since ~10 years ago) but I was curious and tried your repro myself. Thanks for the very simple instructions. Maybe it's useful to see what the error is when you use the octopus strategy to merge only two commits:

``` $ git checkout origin/branch1 $ git merge -s octopus origin/branch2 Trying really trivial in-index merge... error: Merge requires file-level merging Nope. Merge with strategy octopus failed. ```

That "Merge requires file-level merging" is surprising but maybe the "really trivial" is the explanation :) My *guess* is the answer is that the octopus strategy is really old and should be rewritten using the new "ort" strategy (or maybe be integrated into it). I'm afraid I can't think of a workaround for you (other than trying different permutations until it works).

Previous: Elijah NewrenNext: Junio C Hamano
Message 3 of 4 in “Potential bug with octopus merges and symlinks”
  1. Michael McClimonDec 2, 2021
  2. Elijah NewrenDec 4, 2021
  3. Martin von ZweigbergkDec 6, 2021
  4. Junio C HamanoDec 6, 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.