Skip to contentSkip to conversation

Merge format documented?

DISCUSSION Andreas Gruenbacher 4 participants 6 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

#1 lore raw
Quoted 4 lines · Andreas Gruenbacher

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 ;-)

#2 lore raw
Quoted 9 lines · On Monday, 23 March 2009 4:50:24 Junio C Hamano wrote:
Quoted 5 lines · Andreas Gruenbacher

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.

Quoted 7 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

#3 lore raw
Quoted 8 lines · Andreas Gruenbacher
Quoted 7 lines · On Monday, 23 March 2009 4:50:24 Junio C Hamano wrote:
Quoted 5 lines · Andreas Gruenbacher

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:

Quoted 5 lines
Quoted 2 lines

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.

#4 lore raw
Quoted 9 lines · Junio C Hamano
Quoted 7 lines · Andreas Gruenbacher
Quoted 6 lines · On Monday, 23 March 2009 4:50:24 Junio C Hamano wrote:
Quoted 5 lines · Andreas Gruenbacher

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:

Quoted 6 lines
Quoted 4 lines
Quoted 2 lines

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

#5 lore raw
In reply to Andreas Gruenbacher
Quoted 6 lines · Andreas Gruenbacher

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

Quoted 1 line

Does git ever output a ||| section?

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

Signature · 3 lines
Jakub Narebski
Poland
ShadeHawk on #git