Ensure strict matching of context lines when applying with `--whitespace=fix` combined with `--no-ignore-whitespace`. Signed-off-by: Rubén Justo <rjusto@xxxxxxxxx> --- apply.c | 3 ++- t/t4124-apply-ws-rule.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/apply.c b/apply.c index 63e58086f1..0cb9d38e5a 100644 --- a/apply.c +++ b/apply.c @@ -2596,7 +2596,8 @@ static int match_fragment(struct apply_state *state, goto out; } - if (state->ws_error_action != correct_ws_error) { + if (state->ws_error_action != correct_ws_error || + state->ws_ignore_action == ignore_ws_none) { ret = 0; goto out; } diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index 485c7d2d12..573200da67 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -545,6 +545,33 @@ test_expect_success 'whitespace=fix to expand' ' git -c core.whitespace=tab-in-indent apply --whitespace=fix patch ' +test_expect_success 'whitespace=fix honors no-ignore-whitespace' ' + qz_to_tab_space >preimage <<-\EOF && + AZ + BZZ + EOF + qz_to_tab_space >patch <<-\EOF && + diff --git a/preimage b/preimage + --- a/preimage + +++ b/preimage + @@ -1,2 +1,2 @@ + -AZ + +A + BZZZ + EOF + test_must_fail git apply --no-ignore-whitespace --whitespace=fix patch && + qz_to_tab_space >patch <<-\EOF && + diff --git a/preimage b/preimage + --- a/preimage + +++ b/preimage + @@ -1,2 +1,2 @@ + -AZ + +A + BZZ + EOF + git apply --no-ignore-whitespace --whitespace=fix patch +' + test_expect_success 'whitespace check skipped for excluded paths' ' git config core.whitespace blank-at-eol && >used && -- 2.46.0.353.g385c909849