iceman
iceman

Reputation: 2130

What does the line @@ -9,9 +9,10 @@ mean in a diff file?

Can someone please explain the third line in the sample diff output below (i.e., the one that starts with @@)? I understand the changes represented by the remaining lines but am having trouble making sense of that third line...

--- a/code/c-skeleton/Makefile
+++ b/code/c-skeleton/Makefile
@@ -9,9 +9,10 @@
 TEST_SRC=$(wildcard tests/*_tests.c)
 TESTS=$(patsubst %.c,%,$(TEST_SRC))

Upvotes: 0

Views: 69

Answers (1)

Charles Duffy
Charles Duffy

Reputation: 295530

@@ -9,9 +9,10 @@

...specifies where in the source and destination files changes take place, by line number and size of the chunk being edited, both before and after the changes.

Specifically:

@@ -9,9 +9,10 @@
^  ^^ ^ ^^ ^
|  || | || \----- The "10" is the number of lines in the hunk after being
|  || | ||        modified; this patch, then, must add a line, since the
|  || | ||        new count (of 10) is longer than the old count (of 9).
|  || | |\------- This "9" is the line number in the new file where the
|  || | |         modified hunk is placed.
|  || | \-------- This "+" is a hint that the following numbers refer to
|  || |           the new file, after modification.
|  || \---------- This "9" is the number of lines in the hunk before being
|  ||             modified.
|  |\------------ This "9" is the line number in the original file.
|  \------------- This "-" is a hint that the following numbers refer to the
|                 original file.
\---------------- This "@@" is a marker indicating that this is the start of a
                  new hunk.

That is to say: in the original file, the hunk being modified consists of 9 lines starting at line 9; in the destination file, it's 10 lines starting at line 9.

See the detailed description of unified diff format in the GNU diffutils documentation.

Upvotes: 1

Related Questions