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);
@@ -258,8 +258,9 @@
last_line = pos;
SVN_ERR(svn_stream_readline_detect_eol(stream, &line, NULL, &eof,
iterpool));
+ SVN_DBG(("eof = %d, line = '%s'\n", eof, line->data));
- if (! eof)
+ if (! eof)
{
/* Update line offset for next iteration.
* APR has no ftell() :( */
@@ -332,7 +333,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))