0

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?

zsf222
  • 345
  • 1
  • 10

2 Answers2

1

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?

Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52
  • Thanks a lot. Could you please offer me some detailed document explaining its output format or something else where you learned about this knowledge? – zsf222 Dec 22 '16 at 14:59
  • I wish I had detailed documentation; I guessed from the notation, then tested whether that was it in a toy repo. I would expect that the only remaining wrinkle is if there's an octopus join; I don't know what the unified format does with that. – Mark Adelsberger Dec 22 '16 at 15:13
  • Just look at my answer and you will see that it is well documented, directly in the commands man page. ;-) – Vampire Dec 22 '16 at 15:27
  • Why yes, how careless of me not to check your answer form 11 minutes ago before posting my comment 17 minutes ago – Mark Adelsberger Dec 22 '16 at 15:31
  • I didn't say or imply or intended to imply that you were careless. I just told you that you can find further information in my question and also that others who look at this answer and the comments may have a look at my question. No need to be offended. :-) – Vampire Dec 23 '16 at 10:27
1

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.

Vampire
  • 35,631
  • 4
  • 76
  • 102