[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] fix for diff optimization bug

From: Hideki IWAMOTO <h-iwamoto_at_kit.hi-ho.ne.jp>
Date: Mon, 24 Dec 2012 23:43:42 +0900

Hi, Subversion developers.

The optimization of diff inclued in version 1.7 has a bug that
produces incorrect diff on a certain condition.
The attached patch fix it.

diffstat:
 subversion/libsvn_diff/diff_file.c | 6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

Detail of the bug
-----------------

When the identical suffix begins at the boundary of a chunk,
datasource_get_next_token() defined in subversion/libsvn_diff/diff_file.c
does not stop at head of the identical suffix.
Therefore, when one of the identical suffixes of the original file
and the modified file begin from the boundary of a chunk,
excessive tokens are added to the diff tree.

How to reproduce
----------------

$ for ((i=0;i<8256;i++)); do echo 0123456789abcde; done > test.txt
$ hexdump -C test.txt
00000000 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 0a |0123456789abcde.|
*
00020400
$ svn add test.txt; svn ci -m test
A test.txt
Adding test.txt
Transmitting file data .
Committed revision 2.
$ echo 0123456789ABCDE |dd of=test.txt bs=16 seek=64 conv=notrunc
1+0 records in
1+0 records out
$ echo 0123456789ABCDE |dd of=test.txt bs=16 seek=8141 conv=notrunc
1+0 records in
1+0 records out
$ echo 0123456789abcde >> test.txt
$ echo 0123456789abcde >> test.txt
$ hexdump -C test.txt
00000000 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 0a |0123456789abcde.|
*
00000400 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 0a |0123456789ABCDE.|
00000410 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 0a |0123456789abcde.|
*
0001fcd0 30 31 32 33 34 35 36 37 38 39 41 42 43 44 45 0a |0123456789ABCDE.|
0001fce0 30 31 32 33 34 35 36 37 38 39 61 62 63 64 65 0a |0123456789abcde.|
*
00020420
$ svn cat test.txt | diff -u - test.txt
--- - 2012-12-24 22:30:18.760832000 +0900
+++ test.txt 2012-12-24 22:29:24.000000000 +0900
@@ -62,6 +62,7 @@
 0123456789abcde
 0123456789abcde
 0123456789abcde
+0123456789ABCDE
 0123456789abcde
 0123456789abcde
 0123456789abcde
@@ -8138,6 +8139,7 @@
 0123456789abcde
 0123456789abcde
 0123456789abcde
+0123456789ABCDE
 0123456789abcde
 0123456789abcde
 0123456789abcde
$ svn di test.txt
Index: test.txt
===================================================================
--- test.txt (revision 2)
+++ test.txt (working copy)
@@ -62,6 +62,7 @@
 0123456789abcde
 0123456789abcde
 0123456789abcde
+0123456789ABCDE
 0123456789abcde
 0123456789abcde
 0123456789abcde
@@ -8138,6 +8139,7 @@
 0123456789abcde
 0123456789abcde
 0123456789abcde
+0123456789ABCDE
 0123456789abcde
 0123456789abcde
 0123456789abcde
@@ -8188,6 +8190,72 @@
 0123456789abcde
 0123456789abcde
 0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
+0123456789abcde
 0123456789abcde
 0123456789abcde
 0123456789abcde

-- 
Hideki IWAMOTO <h-iwamoto_at_kit.hi-ho.ne.jp>

Received on 2012-12-24 15:44:10 CET

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.