# Merge format documented?

6 messages from 2009-03-23 to 2009-03-27. Participants: Andreas Gruenbacher, Junio C Hamano, Johannes Sixt, Jakub Narebski.
Thread: https://gitlist.dev/t/18477

## Andreas Gruenbacher, 2009-03-23 03:19

Subject: Merge format documented?
Message-ID: <200903230419.50000.agruen@suse.de>
URL: https://gitlist.dev/e/200903230419.50000.agruen%40suse.de

```
Hello,

is the format that git normally uses for indicating merge conflicts in files 
(the <<< === >>> markers) documented somewhere?  How exactly does it differ 
from the diff3 format (<<< ||| === >>>)?  Diff3's -m mode seems to come close 
to what git does, except that git doesn't produce the ||| section:

	$ seq 1 7 > a
	$ seq 1 7 | sed -e 's/4/4b/' > b
	$ seq 1 7 | sed -e 's/3/3c/' > c
	$ diff3 -m c a b
	> 1
	> 2
	> <<<<<<< c
	> 3c
	> 4
	> ||||||| a
	> 3
	> 4
	> =======
	> 3
	> 4b
	> >>>>>>> b
	> 5
	> 6
	> 7

Git's output in this case is:

	> 1
	> 2
	> <<<<<<< this-branch
	> 3c
	> 4
	> =======
	> 3
	> 4b
	> >>>>>>> merged-branch
	> 5
	> 6
	> 7

Does git ever output a ||| section?

Thanks,
Andreas

```

## Junio C Hamano, 2009-03-23 03:50

Subject: Re: Merge format documented?
Message-ID: <7vtz5k99tr.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vtz5k99tr.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <200903230419.50000.agruen@suse.de>

```
Andreas Gruenbacher <agruen@suse.de> writes:

> is the format that git normally uses for indicating merge conflicts in files 
> (the <<< === >>> markers) documented somewhere?  How exactly does it differ 
> from the diff3 format (<<< ||| === >>>)?  Diff3's -m mode seems to come close 
> to what git does, except that git doesn't produce the ||| section:

It is an imitation of output from "merge" program of RCS suite Paul you
know maintains ;-)  Recent versions of git supports merge.conflictstyle
configuration variable and --conflict option in 'git-checkout' to write
the conflicts out in a format that is an imitation of "diff3 -m" output.

As far as I know, neither "git" format is documented anywhere, but I
didn't find an official format specification of the "upstream" formats,
and that is why I keep saying "imitation" in the above paragraph ;-)

```

## Andreas Gruenbacher, 2009-03-23 07:18

Subject: Re: Merge format documented?
Message-ID: <200903230818.20044.agruen@suse.de>
URL: https://gitlist.dev/e/200903230818.20044.agruen%40suse.de
In-Reply-To: <7vtz5k99tr.fsf@gitster.siamese.dyndns.org>

```
On Monday, 23 March 2009 4:50:24 Junio C Hamano wrote:
> Andreas Gruenbacher <agruen@suse.de> writes:
> > is the format that git normally uses for indicating merge conflicts in
> > files (the <<< === >>> markers) documented somewhere?  How exactly does
> > it differ from the diff3 format (<<< ||| === >>>)?  Diff3's -m mode seems
> > to come close to what git does, except that git doesn't produce the |||
> > section:
>
> It is an imitation of output from "merge" program of RCS suite Paul you
> know maintains ;-)

So it's the same format except that diff3's ||| section isn't shown. I was 
wondering if there are any additional tricks.

Patch should support that too, even from the more limited information it has.

> Recent versions of git supports merge.conflictstyle 
> configuration variable and --conflict option in 'git-checkout' to write
> the conflicts out in a format that is an imitation of "diff3 -m" output.
>
> As far as I know, neither "git" format is documented anywhere, but I
> didn't find an official format specification of the "upstream" formats,
> and that is why I keep saying "imitation" in the above paragraph ;-)

The diff info pages describe the diff3 format; that may be enough 
documentation:

  info -f diff -n "Marking Conflicts"

Thanks,
Andreas

```

## Junio C Hamano, 2009-03-23 07:52

Subject: Re: Merge format documented?
Message-ID: <7viqm08ymb.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7viqm08ymb.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <200903230818.20044.agruen@suse.de>

```
Andreas Gruenbacher <agruen@suse.de> writes:

> On Monday, 23 March 2009 4:50:24 Junio C Hamano wrote:
>> Andreas Gruenbacher <agruen@suse.de> writes:
>> > is the format that git normally uses for indicating merge conflicts in
>> > files (the <<< === >>> markers) documented somewhere?  How exactly does
>> > it differ from the diff3 format (<<< ||| === >>>)?  Diff3's -m mode seems
>> > to come close to what git does, except that git doesn't produce the |||
>> > section:
>>
>> It is an imitation of output from "merge" program of RCS suite Paul you
>> know maintains ;-)
>
> So it's the same format except that diff3's ||| section isn't shown. I was 
> wondering if there are any additional tricks.

No additional tricks.

As far as I can remember, the format was not really chosen, but simply
fell out as a natural consequence of using "merge" rather than "diff3" as
a merge backend (we originally used to invoke "merge" from RCS suite
instead of performing file-level merges ourselves), but we could say we
chose "merge" over "diff3 -m" because the output format should be more
familiar than the diff3-m format with |||, especially to anybody who came
from subversion or CVS background.

```

## Johannes Sixt, 2009-03-23 09:17

Subject: Re: Merge format documented?
Message-ID: <49C75393.3030700@viscovery.net>
URL: https://gitlist.dev/e/49C75393.3030700%40viscovery.net
In-Reply-To: <7viqm08ymb.fsf@gitster.siamese.dyndns.org>

```
Junio C Hamano schrieb:
> Andreas Gruenbacher <agruen@suse.de> writes:
> 
>> On Monday, 23 March 2009 4:50:24 Junio C Hamano wrote:
>>> Andreas Gruenbacher <agruen@suse.de> writes:
>>>> is the format that git normally uses for indicating merge conflicts in
>>>> files (the <<< === >>> markers) documented somewhere?  How exactly does
>>>> it differ from the diff3 format (<<< ||| === >>>)?  Diff3's -m mode seems
>>>> to come close to what git does, except that git doesn't produce the |||
>>>> section:
>>> It is an imitation of output from "merge" program of RCS suite Paul you
>>> know maintains ;-)
>> So it's the same format except that diff3's ||| section isn't shown. I was 
>> wondering if there are any additional tricks.
> 
> No additional tricks.

I think there's one additional trick: git moves common parts of the
conflict section outside of the conflict markers, and it even splits the
sections into two if there are common parts between two conflicting lines.

(But that doesn't change how the conflict markers look.)

-- Hannes

```

## Jakub Narebski, 2009-03-27 16:05

Subject: Re: Merge format documented?
Message-ID: <m3y6ur0x4m.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3y6ur0x4m.fsf%40localhost.localdomain
In-Reply-To: <200903230419.50000.agruen@suse.de>

```
Andreas Gruenbacher <agruen@suse.de> writes:

> Hello,
> 
> is the format that git normally uses for indicating merge conflicts in files 
> (the <<< === >>> markers) documented somewhere?  How exactly does it differ 
> from the diff3 format (<<< ||| === >>>)?  Diff3's -m mode seems to come close 
> to what git does, except that git doesn't produce the ||| section:

It is rcmerge / merge from RCS / CVS output format (and I think it is
also format used for other VCS), and IIRC it is equivalent to "diff3
-E" format

> Does git ever output a ||| section?

You can ask for it with merge.conflictstyle configuration variable, or
--conflict=<style> option to git-checkout.

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```
