# [GSoC][PATCH v4] merge-strategies.adoc: detail submodule merge

3 messages from 2025-02-27 to 2025-02-27. Participants: Lucas Seiki Oshiro, Elijah Newren, Junio C Hamano.
Thread: https://gitlist.dev/t/63010

## Lucas Seiki Oshiro, 2025-02-27 01:44

Subject: [GSoC][PATCH v4] merge-strategies.adoc: detail submodule merge
Message-ID: <20250227014406.20527-1-lucasseikioshiro@gmail.com>
URL: https://gitlist.dev/e/20250227014406.20527-1-lucasseikioshiro%40gmail.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 (introduced in 68d03e4a6e44) 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 merge-strategies.adoc describing this behavior.

Helped-by: Junio C Hamano <gitster@pobox.com>
Helped-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
---

Just removing an extra blank line from v3.

Documentation/merge-strategies.adoc | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Documentation/merge-strategies.adoc b/Documentation/merge-strategies.adoc
index 5fc54ec060..c8d81bcda6 100644
--- a/Documentation/merge-strategies.adoc
+++ b/Documentation/merge-strategies.adoc
@@ -22,6 +22,13 @@ ort::
 	was written as a replacement for the previous default
 	algorithm, `recursive`.
 +
+In the case where the path is a submodule, if the submodule commit used on
+one side of the merge is a descendant of the submodule commit used on the
+other side of the merge, Git attempts to fast-forward to the
+descendant. 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.
++
 The 'ort' strategy can take the following options:
 
 ours;;
@@ -96,6 +103,9 @@ recursive::
 	the default strategy for resolving two heads from Git v0.99.9k
 	until v2.33.0.
 +
+For a path that is a submodule, the same caution as 'ort' applies to this
+strategy.
++
 The 'recursive' strategy takes the same options as 'ort'.  However,
 there are three additional options that 'ort' ignores (not documented
 above) that are potentially useful with the 'recursive' strategy:
-- 
2.39.5 (Apple Git-154)


```

## Elijah Newren, 2025-02-27 03:26

Subject: Re: [GSoC][PATCH v4] merge-strategies.adoc: detail submodule merge
Message-ID: <CABPp-BGA530spgVtsU2UO7GyVXL2x=R_80n02pMiPCVA+1SgBg@mail.gmail.com>
URL: https://gitlist.dev/e/CABPp-BGA530spgVtsU2UO7GyVXL2x%3DR_80n02pMiPCVA%2B1SgBg%40mail.gmail.com
In-Reply-To: <20250227014406.20527-1-lucasseikioshiro@gmail.com>

```
On Wed, Feb 26, 2025 at 5:44 PM Lucas Seiki Oshiro
<lucasseikioshiro@gmail.com> wrote:
>
> 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 (introduced in 68d03e4a6e44) 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 merge-strategies.adoc describing this behavior.
>
> Helped-by: Junio C Hamano <gitster@pobox.com>
> Helped-by: Elijah Newren <newren@gmail.com>
> Signed-off-by: Lucas Seiki Oshiro <lucasseikioshiro@gmail.com>
> ---
>
> Just removing an extra blank line from v3.
>
> Documentation/merge-strategies.adoc | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/Documentation/merge-strategies.adoc b/Documentation/merge-strategies.adoc
> index 5fc54ec060..c8d81bcda6 100644
> --- a/Documentation/merge-strategies.adoc
> +++ b/Documentation/merge-strategies.adoc
> @@ -22,6 +22,13 @@ ort::
>         was written as a replacement for the previous default
>         algorithm, `recursive`.
>  +
> +In the case where the path is a submodule, if the submodule commit used on
> +one side of the merge is a descendant of the submodule commit used on the
> +other side of the merge, Git attempts to fast-forward to the
> +descendant. 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.
> ++
>  The 'ort' strategy can take the following options:
>
>  ours;;
> @@ -96,6 +103,9 @@ recursive::
>         the default strategy for resolving two heads from Git v0.99.9k
>         until v2.33.0.
>  +
> +For a path that is a submodule, the same caution as 'ort' applies to this
> +strategy.
> ++
>  The 'recursive' strategy takes the same options as 'ort'.  However,
>  there are three additional options that 'ort' ignores (not documented
>  above) that are potentially useful with the 'recursive' strategy:
> --
> 2.39.5 (Apple Git-154)

Looks good to me; thanks!

```

## Junio C Hamano, 2025-02-27 17:50

Subject: Re: [GSoC][PATCH v4] merge-strategies.adoc: detail submodule merge
Message-ID: <xmqqh64f8efs.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqh64f8efs.fsf%40gitster.g
In-Reply-To: <CABPp-BGA530spgVtsU2UO7GyVXL2x=R_80n02pMiPCVA+1SgBg@mail.gmail.com>

```
Elijah Newren <newren@gmail.com> writes:

> Looks good to me; thanks!

Thanks, both of you.


```
