You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@subversion.apache.org by sv...@apache.org on 2012/09/29 06:02:09 UTC
svn commit: r1391744 - in /subversion/branches/1.7.x: ./ STATUS
subversion/libsvn_diff/parse-diff.c subversion/tests/cmdline/patch_tests.py
Author: svn-role
Date: Sat Sep 29 04:02:09 2012
New Revision: 1391744
URL: http://svn.apache.org/viewvc?rev=1391744&view=rev
Log:
Merge the r1374800 group from trunk:
* r1374800, r1374802, r1389364
Fix issues with applying Git patch files.
Justification:
It's a small change, and it allows applying patches that failed
before.
Votes:
+1 (without r1389364): steveking
+1: stsp, cmpilato, rhuijben
Modified:
subversion/branches/1.7.x/ (props changed)
subversion/branches/1.7.x/STATUS
subversion/branches/1.7.x/subversion/libsvn_diff/parse-diff.c
subversion/branches/1.7.x/subversion/tests/cmdline/patch_tests.py
Propchange: subversion/branches/1.7.x/
------------------------------------------------------------------------------
Merged /subversion/trunk:r1374800,1374802,1389364
Modified: subversion/branches/1.7.x/STATUS
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/STATUS?rev=1391744&r1=1391743&r2=1391744&view=diff
==============================================================================
--- subversion/branches/1.7.x/STATUS (original)
+++ subversion/branches/1.7.x/STATUS Sat Sep 29 04:02:09 2012
@@ -146,15 +146,6 @@ Veto-blocked changes:
Approved changes:
=================
- * r1374800, r1374802, r1389364
- Fix issues with applying Git patch files.
- Justification:
- It's a small change, and it allows applying patches that failed
- before.
- Votes:
- +1 (without r1389364): steveking
- +1: stsp, cmpilato, rhuijben
-
* r1390965
Avoid claiming all tests pass when most fail to run.
Justification:
Modified: subversion/branches/1.7.x/subversion/libsvn_diff/parse-diff.c
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/libsvn_diff/parse-diff.c?rev=1391744&r1=1391743&r2=1391744&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/libsvn_diff/parse-diff.c (original)
+++ subversion/branches/1.7.x/subversion/libsvn_diff/parse-diff.c Sat Sep 29 04:02:09 2012
@@ -1377,8 +1377,7 @@ svn_diff_parse_next_patch(svn_patch_t **
/* Run the state machine. */
for (i = 0; i < (sizeof(transitions) / sizeof(transitions[0])); i++)
{
- if (line->len > strlen(transitions[i].expected_input)
- && starts_with(line->data, transitions[i].expected_input)
+ if (starts_with(line->data, transitions[i].expected_input)
&& state == transitions[i].required_state)
{
SVN_ERR(transitions[i].fn(&state, line->data, *patch,
@@ -1395,19 +1394,24 @@ svn_diff_parse_next_patch(svn_patch_t **
}
else if (state == state_git_tree_seen && line_after_tree_header_read)
{
- /* We have a valid diff header for a patch with only tree changes.
- * Rewind to the start of the line just read, so subsequent calls
- * to this function don't end up skipping the line -- it may
- * contain a patch. */
- SVN_ERR(svn_io_file_seek(patch_file->apr_file, APR_SET, &last_line,
- scratch_pool));
- break;
+ /* git patches can contain an index line after the file mode line */
+ if (!starts_with(line->data, "index "))
+ {
+ /* We have a valid diff header for a patch with only tree changes.
+ * Rewind to the start of the line just read, so subsequent calls
+ * to this function don't end up skipping the line -- it may
+ * contain a patch. */
+ SVN_ERR(svn_io_file_seek(patch_file->apr_file, APR_SET, &last_line,
+ scratch_pool));
+ break;
+ }
}
else if (state == state_git_tree_seen)
{
line_after_tree_header_read = TRUE;
}
- else if (! valid_header_line && state != state_start)
+ else if (! valid_header_line && state != state_start
+ && !starts_with(line->data, "index "))
{
/* We've encountered an invalid diff header.
*
Modified: subversion/branches/1.7.x/subversion/tests/cmdline/patch_tests.py
URL: http://svn.apache.org/viewvc/subversion/branches/1.7.x/subversion/tests/cmdline/patch_tests.py?rev=1391744&r1=1391743&r2=1391744&view=diff
==============================================================================
--- subversion/branches/1.7.x/subversion/tests/cmdline/patch_tests.py (original)
+++ subversion/branches/1.7.x/subversion/tests/cmdline/patch_tests.py Sat Sep 29 04:02:09 2012
@@ -3968,6 +3968,61 @@ def patch_add_and_delete(sbox):
1, # check-props
1) # dry-run
+
+def patch_git_with_index_line(sbox):
+ "apply git patch with 'index' line"
+
+ sbox.build(read_only = True)
+ wc_dir = sbox.wc_dir
+ patch_file_path = make_patch_path(sbox)
+
+ unidiff_patch = [
+ "diff --git a/src/tools/ConsoleRunner/hi.txt b/src/tools/ConsoleRunner/hi.txt\n",
+ "new file mode 100644\n",
+ "index 0000000..c82a38f\n",
+ "--- /dev/null\n",
+ "+++ b/src/tools/ConsoleRunner/hi.txt\n",
+ "@@ -0,0 +1 @@\n",
+ "+hihihihihihi\n",
+ "\ No newline at end of file\n",
+ ]
+
+ svntest.main.file_write(patch_file_path, ''.join(unidiff_patch))
+
+ expected_output = [
+ 'A %s\n' % sbox.ospath('src'),
+ 'A %s\n' % sbox.ospath('src/tools'),
+ 'A %s\n' % sbox.ospath('src/tools/ConsoleRunner'),
+ 'A %s\n' % sbox.ospath('src/tools/ConsoleRunner/hi.txt'),
+ ]
+
+ expected_status = svntest.actions.get_virginal_state(wc_dir, 1)
+ expected_status.add({
+ 'src/' : Item(status='A ', wc_rev=0),
+ 'src/tools' : Item(status='A ', wc_rev=0),
+ 'src/tools/ConsoleRunner/' : Item(status='A ', wc_rev=0),
+ 'src/tools/ConsoleRunner/hi.txt' : Item(status='A ', wc_rev=0),
+ })
+
+ expected_disk = svntest.main.greek_state.copy()
+ expected_disk.add({'src' : Item(),
+ 'src/tools' : Item(),
+ 'src/tools/ConsoleRunner' : Item(),
+ 'src/tools/ConsoleRunner/hi.txt' :
+ Item(contents="hihihihihihi")
+ })
+
+ expected_skip = wc.State('', { })
+
+ svntest.actions.run_and_verify_patch(wc_dir, os.path.abspath(patch_file_path),
+ expected_output,
+ expected_disk,
+ expected_status,
+ expected_skip,
+ None, # expected err
+ 1, # check-props
+ 1) # dry-run
+
########################################################################
#Run the tests
@@ -4011,6 +4066,7 @@ test_list = [ None,
patch_lacking_trailing_eol,
patch_target_no_eol_at_eof,
patch_add_and_delete,
+ patch_git_with_index_line,
]
if __name__ == '__main__':