threads / discuss / 18477

Merge format documented?

Subject: Merge format documented?

## tl;dr

6 messages between Mar 23, 2009 and Mar 27, 2009.

replies: 5people: 4as markdown or json

Andreas Gruenbacher· Mar 23, 2009, 03:19 UTC · lore
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· Mar 23, 2009, 03:50 UTC · re: Andreas Gruenbacher · lore

Re: Merge format documented?

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· Mar 23, 2009, 07:18 UTC · re: Junio C Hamano · lore

Re: Merge format documented?

On Monday, 23 March 2009 4:50:24 Junio C Hamano wrote:
Show 9 quoted lines
> 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.
Show 7 quoted lines
> 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· Mar 23, 2009, 07:52 UTC · re: Andreas Gruenbacher · lore

Re: Merge format documented?

Andreas Gruenbacher <agruen@suse.de> writes:
Show 13 quoted lines
> 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· Mar 23, 2009, 09:17 UTC · re: Junio C Hamano · lore

Re: Merge format documented?

Junio C Hamano schrieb:
Show 15 quoted lines
> 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· Mar 27, 2009, 16:05 UTC · re: Andreas Gruenbacher · lore

Re: Merge format documented?

Andreas Gruenbacher <agruen@suse.de> writes:
Show 6 quoted lines
> 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

← back to recent threads