# Implementing git-am -3 with git-apply -3?

2 messages from 2015-05-26 to 2015-05-26. Participants: Paul Tan, Junio C Hamano.
Thread: https://gitlist.dev/t/39423

## Paul Tan, 2015-05-26 02:49

Subject: Implementing git-am -3 with git-apply -3?
Message-ID: <CACRoPnQWAYPsVVP_ycjBgPVSM_Orx7QmJc96zL5ixRuqi=V_eg@mail.gmail.com>
URL: https://gitlist.dev/e/CACRoPnQWAYPsVVP_ycjBgPVSM_Orx7QmJc96zL5ixRuqi%3DV_eg%40mail.gmail.com

```
Hi Junio,

I noticed that you implemented a 3-way merge fallback[1] in git-apply
that is meant to be similar to git-am's.

I wonder if it is possible to implement the 3-way merge in git-am
using git-apply. Are there any issues/deficiencies that I need to be
aware of?

So far, I noticed that:

* git-apply does not handle renames in the index.

* It could probably try harder at merging submodules (perhaps by using
merge_submodule()?)

[1] http://thread.gmane.org/gmane.comp.version-control.git/201238

Thanks,
Paul

```

## Junio C Hamano, 2015-05-26 03:29

Subject: Re: Implementing git-am -3 with git-apply -3?
Message-ID: <xmqqsiak819q.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqsiak819q.fsf%40gitster.dls.corp.google.com
In-Reply-To: <CACRoPnQWAYPsVVP_ycjBgPVSM_Orx7QmJc96zL5ixRuqi=V_eg@mail.gmail.com>

```
Paul Tan <pyokagan@gmail.com> writes:

> I wonder if it is possible to implement the 3-way merge in git-am
> using git-apply. Are there any issues/deficiencies that I need to be
> aware of?

Anything is possible ;-)

Even though I suspect it might be of significant complexity, it
certainly would be nice if "apply -3" could be taught to do
everything "am -3" would do.

> * git-apply does not handle renames in the index.

True.  The patch application does not really have a global picture,
and that is one of the reasons why I foresee significant complexity
as I said above.  The three-way merge with synthesized virtual base
tree done in "am -3" makes use of established and independent
component that is merge-recursive, and that makes things easier and
keeps things cleaner.

> * It could probably try harder at merging submodules (perhaps by using
> merge_submodule()?)

I am not sure what you mean.  I thought it punts what "am -3" would
punt on, and handles what "am -3" would handle.

```
