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

Re: git merge banch w/ different submodule revision

From
Stefan Beller <sbeller@google.com>
Date
Apr 26, 2018, 17:56 UTC
Message-ID
<CAGZ79kZA_R-5bA6mPdoHkVW-C21pNn_0x6FayhuuXqnOTrmjWw@mail.gmail.com>
In-Reply-To
<1524739599.20251.17.camel@klsmartin.com>

On Thu, Apr 26, 2018 at 3:49 AM, Middelschulte, Leif <Leif.Middelschulte@klsmartin.com> wrote:

Show 26 quoted lines
> Hi,
>
> we're using git-flow as a basic development workflow. However, doing so revealed unexpected merge-behavior by git.
>
> Assume the following setup:
>
> - Repository `S` is sourced by repository `p` as submodule `s`
> - Repository `p` has two branches: `feature_x` and `develop`
> - The revisions sourced via the submodule have a linear history
>
>
> * 1c1d38f (feature_x) update submodule revision to b17e9d9
> | * 3290e69 (HEAD -> develop) update submodule revision to 0598394
> |/
> * cd5e1a5 initial submodule revision
>
>
> Problem case: Merge either branch into the other
>
> Expected behavior: Merge conflict.
>
> Actual behavior: Auto merge without conflicts.
>
> Note 1: A merge conflict does occur, if the sourced revisions do *not* have a linear history
>
> Did I get something wrong about how git resolves merges?

We often treating a submodule as a file from the superproject, but not always. And in case of a merge, git seems to be a bit smarter than treating it as a textfile with two different lines.

See https://github.com/git/git/commit/68d03e4a6e448aa557f52adef92595ac4d6cd4bd (68d03e4a6e (Implement automatic fast-forward merge for submodules, 2010-07-07) to explain the situation you encounter. (specifically merge_submodule at the end of the diff)

> Shouldn't git be like: "hey, you're trying to merge two different contents for the same line" (the submodule's revision)

As we have a history in the submodule we can do more than that and resolve the conflict.

For two lines, you usually need manual intervention (which line to pick, or craft a complete new line out of parts of each line?), whereas for submodule commits you can reason about their dependencies due to their history and not just look at the textual conflict.

Stefan
Previous: Middelschulte, LeifNext: Jacob Keller
Message 2 of 16 in “git merge banch w/ different submodule revision”
  1. Middelschulte, LeifApr 26, 2018
  2. Stefan BellerApr 26, 2018
  3. Jacob KellerApr 26, 2018
  4. Stefan BellerApr 26, 2018
  5. Heiko VoigtApr 30, 2018
  6. Middelschulte, LeifMay 2, 2018
  7. Heiko VoigtMay 3, 2018
  8. Middelschulte, LeifMay 4, 2018
  9. Heiko VoigtMay 4, 2018
  10. Elijah NewrenMay 4, 2018
  11. Middelschulte, LeifMay 7, 2018
  12. Elijah NewrenApr 27, 2018
  13. Elijah NewrenApr 27, 2018
  14. Middelschulte, LeifApr 27, 2018
  15. Elijah NewrenApr 28, 2018
  16. Jacob KellerApr 28, 2018

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.