Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does the “@@…@@” meta line with at signs in svn diff or git diff mean?

Tags:

git

diff

svn

When I use svn diff or git diff it shows lines like:

@@ -1,5 +1,9 @@ 

What do they mean?

like image 573
vietstone Avatar asked Dec 19 '11 08:12

vietstone


People also ask

What does@@ mean in diffs?

Simple example analysis @@ -1,6 +1,4 @@ means: -1,6 means that this piece of the first file starts at line 1 and shows a total of 6 lines. Therefore it shows lines 1 to 6. 1 2 3 4 5 6. - means "old", as we usually invoke it as diff -u old new .

What are the numbers in git diff?

The 'before' value is the sum of the 3 lead context lines, the number of - lines, and the 3 trailing context lines, while the 'after' values is the sum of 3 lead context lines, the number of + lines and the 3 trailing lines.


1 Answers

Those are called (c)hunk headers and contain the range information.

They are surrounded by double at signs @@. They are of the format:

@@ -l,s +l,s @@ 

where l is the starting line number and s is the number of lines the change (c)hunk applies to for each respective file. The - indicates the original file and the + indicates the new (modified) file. Note that it not only shows affected lines, but also context lines.

The -1,5 is in the original file (indicated by the -). It shows that that first line is the start and 5 affected / context lines

The +1,9 is in the new (modified) file (indicated by the +) and again first line is the start and 9 affected / context lines.

More details here: http://en.wikipedia.org/wiki/Diff#Unified_format

like image 138
manojlds Avatar answered Sep 22 '22 10:09

manojlds