Oups, debug statements and trailing white spaces.

Here's a new one.

On Thu, Feb 04, 2010 at 06:27:46PM +0100, Daniel Näslund wrote:
> Hi!
> 
> [[[
> 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): Remove the newline from the end of the patch.
> 
> Patch by: Daniel Näslund <daniel{_AT_}longitudo.com>
> ]]]
Index: subversion/libsvn_diff/parse-diff.c
===================================================================
--- subversion/libsvn_diff/parse-diff.c (revision 906505)
+++ subversion/libsvn_diff/parse-diff.c (arbetskopia)
@@ -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);
+  /* We check for the line lenght 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)
Index: subversion/tests/cmdline/patch_tests.py
===================================================================
--- subversion/tests/cmdline/patch_tests.py     (revision 906505)
+++ subversion/tests/cmdline/patch_tests.py     (arbetskopia)
@@ -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))

Reply via email to