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/08 11:58:40 UTC
svn commit: r907617 - /subversion/trunk/subversion/libsvn_client/patch.c
Author: stsp
Date: Mon Feb 8 10:58:40 2010
New Revision: 907617
URL: http://svn.apache.org/viewvc?rev=907617&view=rev
Log:
* subversion/libsvn_client/patch.c
(get_hunk_info): If the hunk indicates that it wants to create a new file,
reject the hunk if the file already exists. Similarly, reject hunks that
want to modifiy a file which does not exist. Fixes issue #3576.
Modified:
subversion/trunk/subversion/libsvn_client/patch.c
Modified: subversion/trunk/subversion/libsvn_client/patch.c
URL: http://svn.apache.org/viewvc/subversion/trunk/subversion/libsvn_client/patch.c?rev=907617&r1=907616&r2=907617&view=diff
==============================================================================
--- subversion/trunk/subversion/libsvn_client/patch.c (original)
+++ subversion/trunk/subversion/libsvn_client/patch.c Mon Feb 8 10:58:40 2010
@@ -730,11 +730,17 @@
svn_linenum_t matched_line;
/* An original offset of zero means that this hunk wants to create
- * a new file, potentially overwriting all content of an existing
- * file in the WC. Don't bother matching hunks in that case, since
- * the hunk applies at line 1. */
- matched_line = 1;
- if (hunk->original_start > 0 && target->kind == svn_node_file)
+ * a new file. Don't bother matching hunks in that case, since
+ * the hunk applies at line 1. If the file already exists, the hunk
+ * is rejected. */
+ if (hunk->original_start == 0)
+ {
+ if (target->kind == svn_node_file)
+ matched_line = 0;
+ else
+ matched_line = 1;
+ }
+ else if (hunk->original_start > 0 && target->kind == svn_node_file)
{
svn_linenum_t saved_line = target->current_line;
svn_boolean_t saved_eof = target->eof;
@@ -768,6 +774,11 @@
SVN_ERR(seek_to_line(target, saved_line, scratch_pool));
target->eof = saved_eof;
}
+ else
+ {
+ /* The hunk wants to modify a file which doesn't exist. */
+ matched_line = 0;
+ }
(*hi) = apr_palloc(result_pool, sizeof(hunk_info_t));
(*hi)->hunk = hunk;