git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/5] `--whitespace=fix` with `--no-ignore-whitespace`
@ 2024-08-25 10:09 Rubén Justo
  2024-08-25 10:17 ` [PATCH 1/5] apply: introduce `ignore_ws_default` Rubén Justo
                   ` (4 more replies)
  0 siblings, 5 replies; 18+ messages in thread
From: Rubén Justo @ 2024-08-25 10:09 UTC (permalink / raw)
  To: Git List

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(-)

-- 
2.46.0.353.g385c909849

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2024-09-04 18:20 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-25 10:09 [PATCH 0/5] `--whitespace=fix` with `--no-ignore-whitespace` Rubén Justo
2024-08-25 10:17 ` [PATCH 1/5] apply: introduce `ignore_ws_default` Rubén Justo
2024-08-27  1:11   ` Junio C Hamano
2024-08-25 10:18 ` [PATCH 2/5] apply: honor `ignore_ws_none` with `correct_ws_error` Rubén Justo
2024-08-27  0:35   ` Junio C Hamano
2024-08-29  5:07     ` Rubén Justo
2024-08-29 23:13       ` Junio C Hamano
2024-09-03 22:06         ` Rubén Justo
2024-09-04  4:41           ` Junio C Hamano
2024-09-04 18:20             ` Rubén Justo
2024-08-25 10:18 ` [PATCH 3/5] apply: whitespace errors in context lines if we have Rubén Justo
2024-08-27  0:43   ` Junio C Hamano
2024-08-27  1:49     ` Junio C Hamano
2024-08-27 16:12       ` Junio C Hamano
2024-08-27  0:51   ` Junio C Hamano
2024-08-25 10:19 ` [PATCH 4/5] apply: error message in `record_ws_error()` Rubén Justo
2024-08-27  0:44   ` Junio C Hamano
2024-08-25 10:19 ` [PATCH 5/5] t4124: move test preparation into the test context Rubén Justo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).