You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by st...@apache.org on 2010/02/04 19:06:55 UTC

svn commit: r906588 - in /subversion/trunk/subversion: libsvn_diff/parse-diff.c tests/cmdline/patch_tests.py

Author: stsp
Date: Thu Feb  4 18:06:55 2010
New Revision: 906588

URL: http://svn.apache.org/viewvc?rev=906588&view=rev
Log:
Fix bug with 'svn patch' not recognizing hunks with missing newline at
end of patch file.

* subversion/libsvn_diff/parse-diff.c
  (parse_next_hunk): Don't stop reading lines until we've reached eof
    and the line read is empty.

* subversion/tests/cmdline/patch_tests.py
  (patch_with_fuzz): Make this test check for regression by removing
   the newline from the end of the patch used in this test.

Patch by: Daniel Näslund <daniel{_AT_}longitudo.com>

Modified:
    subversion/trunk/subversion/libsvn_diff/parse-diff.c
    subversion/trunk/subversion/tests/cmdline/patch_tests.py

Modified: subversion/trunk/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_diff/parse-diff.c?rev=906588&r1=906587&r2=906588&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/trunk/subversion/libsvn_diff/parse-diff.c Thu Feb  4 18:06:55 2010
@@ -217,6 +217,7 @@
 {
   static const char * const minus = "--- ";
   static const char * const atat = "@@";
+  svn_stringbuf_t *line;
   svn_boolean_t eof, in_hunk, hunk_seen;
   apr_off_t pos, last_line;
   apr_off_t start, end;
@@ -250,7 +251,6 @@
   iterpool = svn_pool_create(scratch_pool);
   do
     {
-      svn_stringbuf_t *line;
 
       svn_pool_clear(iterpool);
 
@@ -332,7 +332,9 @@
             break;
         }
     }
-  while (! eof);
+  /* Check for the line length since a file may not have a newline at the
+   * end and we depend upon the last line to be an empty one. */
+  while (! eof || line->len > 0);
   svn_pool_destroy(iterpool);
 
   if (! eof)

Modified: subversion/trunk/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/tests/cmdline/patch_tests.py?rev=906588&r1=906587&r2=906588&view=diff
==============================================================================
--- subversion/trunk/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/trunk/subversion/tests/cmdline/patch_tests.py Thu Feb  4 18:06:55 2010
@@ -1120,7 +1120,7 @@
     "+A third new line\n",
     " \n",
     " Again, we wish to congratulate you over your email success in our\n"
-    " computer Balloting.\n"
+    " computer Balloting. [No trailing newline here]"
   ]
 
   svntest.main.file_write(patch_file_path, ''.join(unidiff_patch))