Let's say there is no content in a.c file, and then one modifies the file as follows:
#include <stdio.h>
int main()
{
printf("Hello, world\n");
}
Executing svn diff
, I got this message.
--- b.c (revision 1)
+++ b.c (working copy)
@@ -0,0 +1,6 @@
+#include <stdio.h>
+
+int main()
+{
+ printf("Hello, world\n");
+}
Adding one more line in the code:
#include <stdio.h>
int main()
{
printf("Hello, world\n");
printf("Goodbye, world\n");
}
This is the svn diff
result:
--- b.c (revision 2)
+++ b.c (working copy)
@@ -3,4 +3,5 @@
int main()
{
printf("Hello, world\n");
+ printf("Goodbye, world\n");
}
I guess for old(-) and new(+) version, the number after comma is the line of total numbers shown. However, I'm not sure about the number before comma. I think it's where the change starts, but for the first case, the new(+) version has the number 1 not 0.
How one interprets the svn diff
output?
From the Unified diff format on Wikipedia:
@@ -l,s +l,s @@ optional section heading
The hunk range information contains two hunk ranges. The range for the hunk of the original file is preceded by a minus symbol, and the range for the new file is preceded by a plus symbol. Each hunk range is of the format l,s where l is the starting line number and s is the number of lines the change hunk applies to for each respective file. In many versions of GNU diff, each range can omit the comma and trailing value s, in which case s defaults to 1. Note that the only really interesting value is the l line number of the first range; all the other values can be computed from the diff.
I think it's where the change starts, but for the first case, the new(+) version has the number 1 not 0.
Line numbers start at 1, so 1,6
for the new(+) file can be interpreted as you wrote: 1
is the starting line number and 6
is the number of lines shown.
The 0 for the line number must be a special case indicating the file didn't exist. That way you can differentiate between a non-existent old(-) file — 0,0
— and an empty one — 1,0
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With