3

Simple conflict situation during git merge. E.g.:

index e910fdc,492c972..0000000 @@@ -1,10 -1,5 +1,18 @@@ ++<<<<<<< HEAD +1 +2 +a +4 +5 +6 +b +8 +9 - newnewnew ++newnewnew ++======= + aa + aa + cc + aa -aa ++aa ++>>>>>>> br2 

This is diff for not staged both modified file. I'm interested why at the end of each branch block we have lines like:

 +8 +9 - newnewnew ++newnewnew 

but not just

 +8 +9 +newnewnew 

Thanks.

2
  • Would stackoverflow.com/q/29774466/6309 help? Commented Apr 30, 2015 at 19:47
  • @VonC I'm afraid no. I nearly understand ++ meaning. But it seems to me that - line, ++line is the same as just simple ` +line` Commented Apr 30, 2015 at 20:12

1 Answer 1

3

TL;DR

a merge conflict needs to ask the user to judge which side should do what.

It seems the double plus sign line signifies the end of a problematic section - since it is a line BOTH sides of a merge conflict agree should be added into the final merge product.

Long Version

Amazing, I couldn't find any valuable documentation either, but it seems like this is a syntax meant for merge-conflict diff display - at least this is the only location where i've seen this happen.

I think it is based upon git diff syntax, and i will explain: when git performs a merge, it attempts to merge file A into file B. if there is a conflict, since git wants the user to do minimal work, it creates a partial-merge (work-in-progress) file C, and then asks the user to finish the merge by putting A and B on both sides, and letting the user decide how C should look in the end.

in this case, it means there are 3 files being diffed, and a syntax is required per line to show the relationship between all 3. so no we have more than 2 states for a line, depending on whether the merge decided to enter it into the merge (C) file.

a double plus just means that the line exists in both A and B, but is not in C currently, this is a good hint that it SHOULD be in C, but the merger for some reason couldn't make a choice to add it.

so the minus and plus on both 2 first columns of the diff just means whether the line is missing, existant, or added in the right or left files A and B.

here is a basic example:

A:

my original line 1. my original line 2. a unique A line. a new code line 

B:

my original line 1. my original line 2. a unique B line. a new code line 

C (the partial-diff):

my original line 1. my original line 2. a new code line 

lets say A is merged into B to create the partial diff C.

The unified diff window will show something like this:

(replace 0 by a regular space: when its neither minus nor plus)

00my original line 1. 00my original line 2. +0a unique A line. 0+a unique B line. ++a new code line 

As you can see, the line that is in both files on both sides of the merge is marked as double plus - to say "both sides agree this should be added" while the other ones say "each wants a different part to be added inside" - and this is the hint to the section on which the merge actually failed.

Hope i helped a bit, sorry for the messy look, im not good at using the syntax yet..

Sign up to request clarification or add additional context in comments.

1 Comment

Here's a link to the docs, FYI: git-scm.com/docs/git-diff#_combined_diff_format — see the part that reads "A - character in column N means..."

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.