From: Junio C Hamano <gitster@pobox.com>
To: "Rubén Justo" <rjusto@gmail.com>
Cc: Git List <git@vger.kernel.org>
Subject: Re: [PATCH 2/5] apply: honor `ignore_ws_none` with `correct_ws_error`
Date: Tue, 03 Sep 2024 21:41:31 -0700 [thread overview]
Message-ID: <xmqqseugdo90.fsf@gitster.g> (raw)
In-Reply-To: <50d85a93-6711-4b42-87a5-f26b58b8c5c7@gmail.com> ("Rubén Justo"'s message of "Wed, 4 Sep 2024 00:06:10 +0200")
Rubén Justo <rjusto@gmail.com> writes:
> If I understand correctly the example you mentioned, using
> `in_fn_table()` cannot help us in `parse_fragment()`. But I could be
> completely wrong and misunderstanding your intention.
Hmph. It's unfortunate that the control flow goes like this:
apply_all_patches()
-> apply_patch()
-> parse_chunk()
-> parse_single_patch()
-> parse_fragment()
-> use_patch()
-> check_patch_list()
-> check_patch()
-> apply_data()
-> add_to_fn_table()
So deciding if a context line (or a new line for that matter)
contains a whitespace error is done too early in the current code,
and if you want to do this correctly, you'd need to move the check
down so that it happens in apply_one_fragment() that is called in
apply_data(). The rest of the whitespace checks are done there, and
regardless of the "patch that touches the same path twice" issue,
it feels like the right thing to do anyway.
Such a "right" fix might be involved. If we want to punt, I think
you can still inspect the *patch inside parse_single_patch(), and
figure out if the target path of the current fragment you are
looking at has already been touched in the current session (we parse
everything into the patch struct whose fragments member has a
chained list of fragments). Normally that should not be the case.
If we know we are not being fed such a patch with duplicated paths,
we do not have to inspect whitespace issues while parsing a context
' ' line in parse_fragments().
> I still don't see a better option than introducing a new value
> `default`.
As long as we can tell that our input is not a patch that touches
the same path twice, we shouldn't need a new knob or a command line
option. When we are dealing with Git generated patch that does not
mention the same path twice, we can unconditionally say "unless
--ignore-space-change and other options that allow loose matching of
context lines are given, it is an error if context lines do not
exactly match, even when we are correcting for whitespace rule
violations". Otherwise, we may need to keep the current workaround
logic in case a later change has a line as a ' ' context for a file
that an earlier change modified (and fixed with --whitespace=fix).
It is a different story if all you want to change is to add to
--whitespace family of options a new "silent-fix" that makes
corrections in the same way as "fix" (or "strip"), but wihtout
giving any warnings. I think it makes sense to have such a mode,
but that is largely orthogonal to the discussion we are having, I
think, even though it might result in a similar effect visible to
the end-users.
Thanks.
next prev parent reply other threads:[~2024-09-04 4:41 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqseugdo90.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=rjusto@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.