Skip to content

`--whitespace=fix` with `--no-ignore-whitespace`

Rubén Justo git 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest5 patches 12 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/5apply: introduce `ignore_ws_default`apply.c apply.h+2 -11 reply
2/5apply: honor `ignore_ws_none` with `correct_ws_error`apply.c t/t4124-apply-ws-rule.sh+29 -16 replies
3/5apply: whitespace errors in context lines if we haveapply.c t/t4124-apply-ws-rule.sh+4 -24 replies
4/5apply: error message in `record_ws_error()`apply.c+4 -51 reply
5/5t4124: move test preparation into the test contextt/t4124-apply-ws-rule.sh+2 -140 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v1 yet.

Read the v1 thread

Cover letter [PATCH 0/5] `--whitespace=fix` with `--no-ignore-whitespace`

When we see --whitespace=fix we don't consider a possible option:
--no-ignore-whitespace. The following example produces unexpected, at least for me, results:

    $ printf "a \nb\nc\n" >file
    $ git add file
    $ cat >patch <<END
    --- a/file
    +++ b/file
    @@ -1,3 +1,2 @@
     a
    -b
     c
    END
    $ git apply --no-ignore-whitespace --whitespace=fix patch
    $ xxd file
    00000000: 610a 630a                                a.c.

git apply should fail because the context line with 'a' doesn't match the line with 'a ' in the file.

This series aims to make --whitespace=fix strictly match context lines even if they have whitespace errors.

Adding a new ignore_ws_default is intended to reduce the blast radius of changing the behavior of --whitespace=fix. Perhaps there are better ways to do this. I'm open to suggestions.

The last two patches [4-5/5] contain minor code improvements I made while reading the code working on this series. They can be discarded if anyone has concerns.

Thanks.

Rubén Justo (4):
apply: introduce ignore_ws_default
apply: honor ignore_ws_none with correct_ws_error
apply: whitespace errors in context lines if we have ignore_ws_none
apply: error message in record_ws_error()
t4124: move test preparation into the test context

 apply.c                  | 17 ++++++++--------
 apply.h                  |  1 +
 t/t4124-apply-ws-rule.sh | 44 +++++++++++++++++++++++++++-------------
 3 files changed, 40 insertions(+), 22 deletions(-)
Signature · 1 line
2.46.0.353.g385c909849