git diff: many patches with three '@' symbol

162 views Asked by At

I am writing an automatic tool based on git show, which relies on git diff command. I wrote a small parser which takes the output of git show as the text to parse, and in most situations in the result the lines start with '@@' indicates which lines it will compare.

However, I met an situation like this:

@@@ -460,22 -415,8 +460,22 @@@

What does that mean? Is it possible that there will be even more (4 or more) '@' symbols with even more subtle meanings?

2

There are 2 answers

0
Vampire On BEST ANSWER

You are showing a merge in combined diff format. If you look at the man-page of git show, it has a complete section about combined diff format, when it is used and how it looks like. Also in the initial description of git show it says that merges will be shown like git diff-tree --cc which also refers to the combined diff format.

And yes, there can be more than three @ symbols. There will be one per parent commit + 1. So if you have a merge with three parents (a so-called octupus merge), there will be four at signs. If you have four parents, there will be five at signs and so on.

5
Mark Adelsberger On

It looks to me like you're doing a show on a merge, and this hunk differs from both parents; could that be the explanation?