Index: subversion/include/svn_subst.h =================================================================== --- subversion/include/svn_subst.h (revision 1058560) +++ subversion/include/svn_subst.h (working copy) @@ -615,8 +615,10 @@ svn_error_t *svn_subst_translate_string(svn_string * *translated_line_endings to @c TRUE if at least one line ending was * changed to LF, or to @c FALSE otherwise. * - * Recognized line endings are LF, CR, CRLF. If @a value has inconsistent - * line endings, return @c SVN_ERR_IO_INCONSISTENT_EOL. + * If @a value has an inconsistent line ending style, then: if @a repair + * is @c FALSE, return @c SVN_ERR_IO_INCONSISTENT_EOL, else if @a repair is + * @c TRUE, convert any line ending in @a value to "\n" in + * @a *new_value. Recognized line endings are: "\n", "\r", and "\r\n". * * Set @a *new_value to the translated string, allocated in @a result_pool. * @@ -630,6 +632,7 @@ svn_subst_translate_string2(svn_string_t **new_val svn_boolean_t *translated_line_endings, const svn_string_t *value, const char *encoding, + svn_boolean_t repair, apr_pool_t *result_pool, apr_pool_t *scratch_pool); Index: subversion/libsvn_subr/subst.c =================================================================== --- subversion/libsvn_subr/subst.c (revision 1058560) +++ subversion/libsvn_subr/subst.c (working copy) @@ -1863,6 +1863,7 @@ svn_subst_translate_string2(svn_string_t **new_val svn_boolean_t *translated_line_endings, const svn_string_t *value, const char *encoding, + svn_boolean_t repair, apr_pool_t *result_pool, apr_pool_t *scratch_pool) { @@ -1892,7 +1893,7 @@ svn_subst_translate_string2(svn_string_t **new_val translated_line_endings, val_utf8, "\n", /* translate to LF */ - FALSE, /* no repair */ + repair, NULL, /* no keywords */ FALSE, /* no expansion */ scratch_pool)); Index: subversion/libsvn_subr/deprecated.c =================================================================== --- subversion/libsvn_subr/deprecated.c (revision 1058560) +++ subversion/libsvn_subr/deprecated.c (working copy) @@ -256,7 +256,7 @@ svn_subst_translate_string(svn_string_t **new_valu apr_pool_t *pool) { return svn_subst_translate_string2(new_value, NULL, NULL, value, - encoding, pool, pool); + encoding, FALSE, pool, pool); } svn_error_t * Index: subversion/svn/util.c =================================================================== --- subversion/svn/util.c (revision 1058560) +++ subversion/svn/util.c (working copy) @@ -485,8 +485,8 @@ svn_cl__edit_string_externally(svn_string_t **edit if (as_text) { err = svn_subst_translate_string2(edited_contents, FALSE, FALSE, - *edited_contents, encoding, pool, - pool); + *edited_contents, encoding, FALSE, + pool, pool); if (err) { err = svn_error_quick_wrap @@ -713,7 +713,7 @@ svn_cl__get_log_message(const char **log_msg, log_msg_str->len = log_msg_buf->len; SVN_ERR_W(svn_subst_translate_string2(&log_msg_str, FALSE, FALSE, log_msg_str, lmb->message_encoding, - pool, pool), + FALSE, pool, pool), _("Error normalizing log message to internal format")); *log_msg = log_msg_str->data; Index: subversion/svn/propset-cmd.c =================================================================== --- subversion/svn/propset-cmd.c (revision 1058560) +++ subversion/svn/propset-cmd.c (working copy) @@ -86,8 +86,8 @@ svn_cl__propset(apr_getopt_t *os, and LF line endings. All other propvals are taken literally. */ if (svn_prop_needs_translation(pname_utf8)) SVN_ERR(svn_subst_translate_string2(&propval, NULL, NULL, propval, - opt_state->encoding, scratch_pool, - scratch_pool)); + opt_state->encoding, FALSE, + scratch_pool, scratch_pool)); else if (opt_state->encoding) return svn_error_create (SVN_ERR_UNSUPPORTED_FEATURE, NULL, Index: subversion/svn/lock-cmd.c =================================================================== --- subversion/svn/lock-cmd.c (revision 1058560) +++ subversion/svn/lock-cmd.c (working copy) @@ -74,7 +74,7 @@ get_comment(const char **comment, svn_client_ctx_t /* Translate to UTF8/LF. */ SVN_ERR(svn_subst_translate_string2(&comment_string, NULL, NULL, comment_string, opt_state->encoding, - pool, pool)); + FALSE, pool, pool)); *comment = comment_string->data; return SVN_NO_ERROR; Index: subversion/svnadmin/main.c =================================================================== --- subversion/svnadmin/main.c (revision 1058560) +++ subversion/svnadmin/main.c (working copy) @@ -1184,7 +1184,7 @@ set_revprop(const char *prop_name, const char *fil prop_value->len = file_contents->len; SVN_ERR(svn_subst_translate_string2(&prop_value, NULL, NULL, prop_value, - NULL, pool, pool)); + NULL, FALSE, pool, pool)); /* Open the filesystem */ SVN_ERR(open_repos(&repos, opt_state->repository_path, pool)); Index: subversion/tests/libsvn_subr/subst_translate-test.c =================================================================== --- subversion/tests/libsvn_subr/subst_translate-test.c (revision 1058560) +++ subversion/tests/libsvn_subr/subst_translate-test.c (working copy) @@ -66,7 +66,7 @@ test_svn_subst_translate_string2(apr_pool_t *pool) SVN_ERR(svn_subst_translate_string2(&new_value, NULL, &translated_line_endings, - source_string, "ISO-8859-1", + source_string, "ISO-8859-1", FALSE, pool, pool)); SVN_TEST_STRING_ASSERT(new_value->data, t->expected_str); SVN_TEST_ASSERT(translated_line_endings == t->translated_line_endings); @@ -76,16 +76,42 @@ test_svn_subst_translate_string2(apr_pool_t *pool) translated_line_endings = ! t->translated_line_endings; SVN_ERR(svn_subst_translate_string2(&new_value, &translated_to_utf8, &translated_line_endings, - source_string, "ISO-8859-1", + source_string, "ISO-8859-1", FALSE, pool, pool)); SVN_TEST_STRING_ASSERT(new_value->data, t->expected_str); SVN_TEST_ASSERT(translated_to_utf8 == t->translated_to_utf8); SVN_TEST_ASSERT(translated_line_endings == t->translated_line_endings); } + /* Test that when REPAIR is FALSE, SVN_ERR_IO_INCONSISTENT_EOL is returned. */ + { + svn_string_t *source_string = svn_string_create(" \r \r\n \n ", pool); + svn_string_t *new_value = NULL; + SVN_TEST_ASSERT( + svn_subst_translate_string2(&new_value, NULL, NULL, source_string, + "ISO-8859-1", FALSE, pool, pool)->apr_err + == SVN_ERR_IO_INCONSISTENT_EOL); + } + return SVN_NO_ERROR; } +static svn_error_t * +test_repairing_svn_subst_translate_string2(apr_pool_t *pool) +{ + { + svn_string_t *source_string = svn_string_create(" \r \r\n \n ", pool); + svn_string_t *new_value = NULL; + SVN_ERR(svn_subst_translate_string2(&new_value, NULL, NULL, source_string, + "ISO-8859-1", TRUE, pool, pool)); + SVN_TEST_ASSERT(new_value != NULL); + SVN_TEST_ASSERT(new_value->data != NULL); + SVN_TEST_STRING_ASSERT(new_value->data, " \n \n \n "); + } + + return SVN_NO_ERROR; +} + /*static svn_error_t * test_svn_subst_copy_and_translate4(apr_pool_t *pool) { @@ -142,6 +168,8 @@ struct svn_test_descriptor_t test_funcs[] = SVN_TEST_NULL, SVN_TEST_PASS2(test_svn_subst_translate_string2, "test svn_subst_translate_string2()"), + SVN_TEST_PASS2(test_repairing_svn_subst_translate_string2, + "test repairing svn_subst_translate_string2()"), SVN_TEST_PASS2(test_svn_subst_translate_cstring2, "test svn_subst_translate_cstring2()"), SVN_TEST_NULL