Uploaded image for project: 'Subversion'
  1. Subversion
  2. SVN-4283

When the identical suffix starts at chunk boundary, "svn diff" produces incorrect diff

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • trunk
    • 1.8.0
    • libsvn_diff
    • None

    Description

      The optimization of diff inclued in version 1.7 has a bug that
      produces incorrect diff on a certain condition.
      I will attach a patch fix it. 
      
      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
      

      Original issue reported by hideki_iwamoto

      Attachments

        1. 1_issu4283-trunk.patch
          6 kB
          Subversion Importer

        Activity

          People

            Unassigned Unassigned
            subversion-importer Subversion Importer
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: