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

[GSoC][RFC PATCH] git-merge.adoc: detail submodule merge

From
Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
Date
Feb 17, 2025, 23:28 UTC
Message-ID
<20250217232847.8567-1-lucasseikioshiro@gmail.com>

Submodule merges are, in general, similar to other merges based on oid three-way-merge. When a conflict happens, however, Git has two special cases on handling the conflict before yielding it to the user. From the merge-ort and merge-recursive sources:

- "Case #1: a is contained in b or vice versa": both strategies try to
perform a fast-forward in the submodules if the commit referred by the
conflicted submodule is descendant of another;
- "Case #2: There are one or more merges that contain a and b in the
submodule.  If there is only one, then present it as a suggestion to the
user, but leave it marked unmerged so the user needs to confirm the
resolution."
Add a small paragraph on git-merge.adoc describing this behavior.
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---
Hi,

This is a "scratch-my-own-itch" documentation patch. Some years ago I was questioned why some submodule merges on GitHub lead to conflicts while locally they didn't. I only could find a answer for that reading the merge-ort source code, then a wrote a blog post about that, which you check here: https://lucasoshiro.github.io/posts-en/2022-03-12-merge-submodule/

Thus, this patch adds to the official documentation what I found at the time. I wasn't certain if this should belong to the submodule or merge documentation, so, by now, I'm sending it as a merge documentation patch.

 Documentation/git-merge.adoc | 7 +++++++
 1 file changed, 7 insertions(+)
diff --git a/Documentation/git-merge.adoc b/Documentation/git-merge.adoc
index 64281d6d44..7b12c0d648 100644
--- a/Documentation/git-merge.adoc
+++ b/Documentation/git-merge.adoc
@@ -205,6 +205,13 @@ happens:
    same and the index entries for them stay as they were,
    i.e. matching `HEAD`.
 
+In the case where the path is a submodule, if the commit referred by it in HEAD
+is descendant of the one referred by it in MERGE_HEAD or vice-versa, Git
+attempts to fast-forward to the descendant, when using `ort` or `recursive`
+strategies. Otherwise, Git will treat this case as a conflict, suggesting as a
+resolution a submodule commit that is descendant of the conflicting ones, if one
+exists.
+
 If you tried a merge which resulted in complex conflicts and
 want to start over, you can recover with `git merge --abort`.
 
-- 
2.39.5 (Apple Git-154)
Next: Elijah Newren
Message 1 of 5 in “git-merge.adoc: detail submodule merge”
  1. Lucas Seiki OshiroFeb 17, 2025
  2. Elijah NewrenFeb 18, 2025
  3. Lucas OshiroFeb 18, 2025
  4. Elijah NewrenFeb 18, 2025
  5. Lucas OshiroFeb 19, 2025

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.