# What is the scenario for a commit with 3 or more parents

9 messages from 2010-07-29 to 2010-07-29. Participants: Bradley Wagner, Shawn O. Pearce, Sverre Rabbelier, Joshua Juran, Junio C Hamano.
Thread: https://gitlist.dev/t/24566

## Bradley Wagner, 2010-07-29 02:05

Subject: What is the scenario for a commit with 3 or more parents
Message-ID: <AANLkTikMRa_LrD2fU9Piv3GW2H0r7Jf_9s5iM0wc9t6s@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikMRa_LrD2fU9Piv3GW2H0r7Jf_9s5iM0wc9t6s%40mail.gmail.com

```
I was reading over the Specifying Revisions section in the man entry
gitrevisions. I understand having 2 parent commits with a merge.

I was trying to understand the HEAD^2 style syntax and wondering where
HEAD^3 would be used. From the example diagram, this would be Commit B
but I'm unclear how this would ever happen. Is this some kind of
multi-way merge?

Does git log show the parents in their ordinal order in the "Merge:" line?

```

## Shawn O. Pearce, 2010-07-29 02:19

Subject: Re: What is the scenario for a commit with 3 or more parents
Message-ID: <20100729021946.GG25268@spearce.org>
URL: https://gitlist.dev/e/20100729021946.GG25268%40spearce.org
In-Reply-To: <AANLkTikMRa_LrD2fU9Piv3GW2H0r7Jf_9s5iM0wc9t6s@mail.gmail.com>

```
Bradley Wagner <bradley.wagner@hannonhill.com> wrote:
> I was reading over the Specifying Revisions section in the man entry
> gitrevisions. I understand having 2 parent commits with a merge.
> 
> I was trying to understand the HEAD^2 style syntax and wondering where
> HEAD^3 would be used. From the example diagram, this would be Commit B
> but I'm unclear how this would ever happen. Is this some kind of
> multi-way merge?

Yes.  Its called an octopus merge.  It happpens sometimes when
merging 2 or more otherwise fairly isolated changes in a single
shot.  E.g. `git merge feature-a feature-b thing-c`.
 
> Does git log show the parents in their ordinal order in the "Merge:" line?

Yes.

-- 
Shawn.

```

## Sverre Rabbelier, 2010-07-29 17:55

Subject: Re: What is the scenario for a commit with 3 or more parents
Message-ID: <AANLkTik-wOB-iEGK8EnW1Rdk9wwc1E86tYoBU26WepYJ@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTik-wOB-iEGK8EnW1Rdk9wwc1E86tYoBU26WepYJ%40mail.gmail.com
In-Reply-To: <20100729021946.GG25268@spearce.org>

```
Heya,

On Wed, Jul 28, 2010 at 21:19, Shawn O. Pearce <spearce@spearce.org> wrote:
> Yes.  Its called an octopus merge.  It happpens sometimes when
> merging 2 or more otherwise fairly isolated changes in a single
> shot.  E.g. `git merge feature-a feature-b thing-c`.

Do we have an explanation anywhere as to when one would use a octopus merge?

-- 
Cheers,

Sverre Rabbelier

```

## Bradley Wagner, 2010-07-29 17:57

Subject: Re: What is the scenario for a commit with 3 or more parents
Message-ID: <AANLkTimxcnTkJLqX6qfdYWHrgXOzZ-Rk_48KHyip39ay@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTimxcnTkJLqX6qfdYWHrgXOzZ-Rk_48KHyip39ay%40mail.gmail.com
In-Reply-To: <AANLkTik-wOB-iEGK8EnW1Rdk9wwc1E86tYoBU26WepYJ@mail.gmail.com>

```
On Thu, Jul 29, 2010 at 1:55 PM, Sverre Rabbelier <srabbelier@gmail.com> wrote:
>
> Heya,
>
> On Wed, Jul 28, 2010 at 21:19, Shawn O. Pearce <spearce@spearce.org> wrote:
> > Yes.  Its called an octopus merge.  It happpens sometimes when
> > merging 2 or more otherwise fairly isolated changes in a single
> > shot.  E.g. `git merge feature-a feature-b thing-c`.
>
> Do we have an explanation anywhere as to when one would use a octopus merge?

Another question I had about this: isn't this documentation about
"multi-way merge" inaccurate:
http://book.git-scm.com/5_advanced_branching_and_merging.html.

Sounds like it's not equivalent to merging each branch individually.

>
> --
> Cheers,
>
> Sverre Rabbelier

```

## Joshua Juran, 2010-07-29 18:10

Subject: Re: What is the scenario for a commit with 3 or more parents
Message-ID: <C77AA970-4288-487F-9568-E86CF776FCED@gmail.com>
URL: https://gitlist.dev/e/C77AA970-4288-487F-9568-E86CF776FCED%40gmail.com
In-Reply-To: <AANLkTik-wOB-iEGK8EnW1Rdk9wwc1E86tYoBU26WepYJ@mail.gmail.com>

```
On Jul 29, 2010, at 10:55 AM, Sverre Rabbelier wrote:

> Heya,
>
> On Wed, Jul 28, 2010 at 21:19, Shawn O. Pearce <spearce@spearce.org>  
> wrote:
>> Yes.  Its called an octopus merge.  It happpens sometimes when
>> merging 2 or more otherwise fairly isolated changes in a single
>> shot.  E.g. `git merge feature-a feature-b thing-c`.
>
> Do we have an explanation anywhere as to when one would use a  
> octopus merge?

How about if you had two (or more) components with a shared protocol,  
and you updated each to speak a new (and incompatible) protocol.  The  
changes to each component might be done in separate topic branches,  
but you'd want to merge them all at once.

$ git checkout master
$ git merge client-v2 server-v2

Josh

```

## Sverre Rabbelier, 2010-07-29 18:22

Subject: Re: What is the scenario for a commit with 3 or more parents
Message-ID: <AANLkTikpLHdMzbpix8jnyS6YwSkgie=Ts44AJP5dA4=T@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTikpLHdMzbpix8jnyS6YwSkgie%3DTs44AJP5dA4%3DT%40mail.gmail.com
In-Reply-To: <C77AA970-4288-487F-9568-E86CF776FCED@gmail.com>

```
Heya,

On Thu, Jul 29, 2010 at 13:10, Joshua Juran <jjuran@gmail.com> wrote:
> How about if you had two (or more) components with a shared protocol, and
> you updated each to speak a new (and incompatible) protocol.  The changes to
> each component might be done in separate topic branches, but you'd want to
> merge them all at once.
>
> $ git checkout master
> $ git merge client-v2 server-v2

Very nice example, but do we have it _documented_ anywhere? If not, it
would be great if you could add that somewhere :)

-- 
Cheers,

Sverre Rabbelier

```

## Junio C Hamano, 2010-07-29 20:12

Subject: Re: What is the scenario for a commit with 3 or more parents
Message-ID: <7vzkxarqry.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzkxarqry.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTikpLHdMzbpix8jnyS6YwSkgie=Ts44AJP5dA4=T@mail.gmail.com>

```
Sverre Rabbelier <srabbelier@gmail.com> writes:

> Heya,
>
> On Thu, Jul 29, 2010 at 13:10, Joshua Juran <jjuran@gmail.com> wrote:
>> How about if you had two (or more) components with a shared protocol, and
>> you updated each to speak a new (and incompatible) protocol.  The changes to
>> each component might be done in separate topic branches, but you'd want to
>> merge them all at once.
>>
>> $ git checkout master
>> $ git merge client-v2 server-v2
>
> Very nice example, but do we have it _documented_ anywhere? If not, it
> would be great if you could add that somewhere :)

Please don't.

I actually do not think the "client-server" is a good example from
software engineering point-of-view, as it means that everybody talks
version 1 before that merge and everybody talks version 2 after that
merge, i.e. you have a flag day event.

Think for 5 seconds how one would have tested client-v2 topic alone in
isolation.

The only transition plan that works in real life is for the updated client
to talk fine with a server without version 2 support, while being prepared
to talk the newer protocol if the server supports it.  The server side
needs to be arranged in a similar way.

If that is how these topics were developed, you should be able to merge
client-v2 topic and then server-v2 topic, or in the other order, without
breaking anything on the master branch.

The original idea of Octopus was that, when

 (1) you have many topics that are not inter-related; _and_

 (2) merging all of them in any random order wouldn't have made any
     difference in the resulting history, either in the end result nor in
     any of the intermediate steps,

it is not worth to serialize the merge order and create extra merge
commits.

I think we tend to discourage the use of Octopus these days, as people are
fallible.  When topics that they originally thought are independent turn
out to have funny interactions among each other, having an Octopus merge
across them tends to make bisection much less efficient in order to find
the real culprit in the history when you find something is broken.

Compared to that downside, it is not worth to use an Octopus, only to have
a smaller number of merge commits and a cool-looking lantern-shaped merge
commit in the history.

```

## Sverre Rabbelier, 2010-07-29 20:50

Subject: Re: What is the scenario for a commit with 3 or more parents
Message-ID: <AANLkTinT4SpdYHfaiwPqVHDEaN6gEr-3kyHbE4-g=HN5@mail.gmail.com>
URL: https://gitlist.dev/e/AANLkTinT4SpdYHfaiwPqVHDEaN6gEr-3kyHbE4-g%3DHN5%40mail.gmail.com
In-Reply-To: <7vzkxarqry.fsf@alter.siamese.dyndns.org>

```
Heya,

On Thu, Jul 29, 2010 at 15:12, Junio C Hamano <gitster@pobox.com> wrote:
> Compared to that downside, it is not worth to use an Octopus, only to have
> a smaller number of merge commits and a cool-looking lantern-shaped merge
> commit in the history.

Ok, do we have _that_ documented anywhere?

-- 
Cheers,

Sverre Rabbelier

```

## Junio C Hamano, 2010-07-29 21:01

Subject: Re: What is the scenario for a commit with 3 or more parents
Message-ID: <7vvd7yroia.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vvd7yroia.fsf%40alter.siamese.dyndns.org
In-Reply-To: <AANLkTinT4SpdYHfaiwPqVHDEaN6gEr-3kyHbE4-g=HN5@mail.gmail.com>

```
Sverre Rabbelier <srabbelier@gmail.com> writes:

> On Thu, Jul 29, 2010 at 15:12, Junio C Hamano <gitster@pobox.com> wrote:
>> Compared to that downside, it is not worth to use an Octopus, only to have
>> a smaller number of merge commits and a cool-looking lantern-shaped merge
>> commit in the history.
>
> Ok, do we have _that_ documented anywhere?

Outside the list archive, I don't think so.

```
