Fix #3610 - 'svn patch' should be able to ignore whitespace changes.
Mail clients often mess with whitespaces in different ways:
* remove leading whitespaces at the beginning of a line
* convert tabs to spaces
* remove trailing whitespaces at the end of a line
With the --ignore-whitespaces, we allow hunks to be matched without
taking whitespaces into account. The matching hunks will be applied
as-is without any attempt to guess what the correct whitespaces should
be.
Since this matching is not as restrictive as the usual one, there's a
risk of erroneus behaviour, i.e. matching a patch with all leading
spaces removed makes it impossible to distinguish between a context line
and some other line, intended to be ignored.
If people don't like the result of patching, they can edit the patch
to their liking and re-apply it (or ask the submitter to resubmit
the patch -- mangled patches are usually the submitter's fault).
* subversion/include/svn_diff.h
(svn_diff_parse_next_patch): Add IGNORE_WHITESPACES parameter.
* subversion/include/svn_client.h
(svn_client_patch): Add IGNORE_WHITESPACES parameter.
* subversion/libsvn_client/patch.c
(apply_patches_baton_t): Add IGNORE_WHITESPACES field.
(match_hunk): Add IGNORE_WHITESPACES parameter. if ignore_whitespaces
is set, do a matching with all whitespaces removed.
(scan_for_match,
get_hunk_info,
apply_one_patch): Add IGNORE_WHITESPACES parameter.
(apply_patches): Pass IGNORE_WHITESPACES parameter from baton to
svn_diff_parse_next_patch() and apply_one_patch().
(svn_client_patch): Add IGNORE_WHITESPACES. Pass it on via baton to
apply_patches.
* subversion/libsvn_diff/parse-diff.c
(parse_next_hunk): Add IGNORE_WHITESPACES parameter. Treat lines not
starting with '+' or '-' as context lines if the
ignore_whitespaces parameter is set.
(svn_diff_parse_next_patch): Add IGNORE_WHITESPACES parameter.
* subversion/tests/libsvn_diff/parse-diff-test.c
(test_parse_unidiff): Update callers to use the IGNORE_WHITESPACES
parameter.
* subversion/tests/libsvn_client/client-test.c
(test_patch): Update callers to use the IGNORE_WHITESPACES parameter.
* subversion/tests/cmdline/patch_tests.py
(patch_with_ignore_whitespaces): New.
(test_list): Add new test.
* subversion/svn/cl.h
(svn_cl__opt_state_t): Add IGNORE_WHITESPACES field.
* subversion/svn/main.c
(svn_cl__longopt_t): Add IGNORE_WHITESPACES field.
(svn_cl__cmd_table): Add --ignore-whitespaces option.
(main): Handle --ignore-whitespaces option.
git-svn-id: https://svn.apache.org/repos/asf/subversion/trunk@934569 13f79535-47bb-0310-9956-ffa450edef68
10 files changed