[
https://issues.apache.org/jira/browse/SVN-4609?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15057997#comment-15057997
]
Bert Huijben commented on SVN-4609:
-----------------------------------
[[
Index: dev/subversion/libsvn_diff/parse-diff.c
===================================================================
--- dev/subversion/libsvn_diff/parse-diff.c (revision 1720139)
+++ dev/subversion/libsvn_diff/parse-diff.c (working copy)
@@ -1316,10 +1316,19 @@ parse_next_hunk(svn_diff_hunk_t **hunk,
* up skipping the line -- it may contain a patch or hunk header. */
SVN_ERR(svn_io_file_seek(apr_file, APR_SET, &last_line, scratch_pool));
if (hunk_seen && start < end)
{
+ /* Did we get the number of context lines announced in the header?
+
+ If not... let's limit the number from the header to what we
+ actually have */
+ if (original_lines)
+ (*hunk)->original_length -= original_lines;
+ if (modified_lines)
+ (*hunk)->modified_length -= modified_lines;
+
(*hunk)->patch = patch;
(*hunk)->apr_file = apr_file;
(*hunk)->leading_context = leading_context;
(*hunk)->trailing_context = trailing_context;
(*hunk)->diff_text_range.start = start;
]]
Makes this new test PASS: applies the patch with no fuzz to the expected result.
I would prefer a solution that notes that this patch misses essential
information, but I'm not sure if we can do that in a 1.8.x/1.9.x compatible way.
> patch hunk with missing trailing context results in extra delete
> ----------------------------------------------------------------
>
> Key: SVN-4609
> URL: https://issues.apache.org/jira/browse/SVN-4609
> Project: Subversion
> Issue Type: Bug
> Affects Versions: all
> Reporter: Philip Martin
>
> Consider a file with 5 lines:
> a
> b
> c
> d
> e
> and a patch hunk that modifies the third line:
> @@ -1,5 +1,5 @@
> a
> b
> -c
> +cc
> d
> e
> Remove the final line of context, the 'e' line, and then apply the patch. GNU
> diff will apply with fuzz 1 and modify only the 'c' line while svn patch will
> modify the 'c' line and delete the 'e' line.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)