#777479 subversion: svn diff outputs 2 chunks instead of 1 when there are 6 consecutive unmodified lines

Package:
subversion
Source:
subversion
Description:
Advanced version control system
Submitter:
Vincent Lefevre
Date:
2015-02-10 01:54:05 UTC
Severity:
minor
#777479#5
Date:
2015-02-08 18:19:14 UTC
From:
To:
Contrary to the "diff" utility, "svn diff" outputs 2 chunks instead
of 1 when there are 6 consecutive unmodified lines.

To reproduce the bug, create a file with "seq 14" and commit it.
Then modify the lines 4 and 11 (e.g. add a "b" character). I get
with Subversion's internal diff:

$ svn diff
Index: f
===================================================================
--- f   (revision 1)
+++ f   (working copy)
@@ -1,7 +1,7 @@
 1
 2
 3
-4
+4b
 5
 6
 7
@@ -8,7 +8,7 @@
 8
 9
 10
-11
+11b
 12
 13
 14

while the "diff" command gives:

$ svn --diff-cmd diff diff
Index: f
===================================================================
--- f   (revision 1)
+++ f   (working copy)
@@ -1,14 +1,14 @@
 1
 2
 3
-4
+4b
 5
 6
 7
 8
 9
 10
-11
+11b
 12
 13
 14

#777479#10
Date:
2015-02-10 01:09:15 UTC
From:
To:
Control: severity -1 minor

I don't think svn claims to produce identical diffs to that of the diff
command, so this is at most a minor issue, if not wishlist.

Also, the diffs are functionally equivalent, so I'm not sure how this
matters other than the diffs being different.

Cheers,

#777479#17
Date:
2015-02-10 01:50:38 UTC
From:
To:
Well, actually, what initially confused me with the "svn diff" output
is that I thought that two output chunks were necessarily disjoint
and non adjacent[*]. So, it seemed to me that there was a problem
with my file, until I noticed that the chunks output by "svn diff"
were adjacent. I hope that my bug report is more clear now.

[*] AFAIK, this is always the case with GNU diff, and this is why
I thought that this was a general rule for the unified diff format.

Now, what's interesting is what POSIX says:

http://pubs.opengroup.org/onlinepubs/9699919799/utilities/diff.html

  "If -U n is specified, the output shall contain no more than
  n consecutive unaffected lines; and if the output contains an
  affected line and this line is adjacent to up to n consecutive
  unaffected lines in the corresponding file, the output shall
  contain these unaffected lines. -u shall act like -U3."

So, it appears that "svn diff" follows POSIX here (but it doesn't when
there are exactly 5 consecutive unaffected lines). And GNU diff more
generally doesn't follow POSIX, even though this page later says that
the -u and -U options come from GNU diff!

At least there is a lack of specification for "svn diff". But I think
that a rule requiring disjoint and non adjacent chunks is intuitively
better for a human reader.