From: Thierry Reding <thierry.reding@gmail.com>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Taylor Blau <me@ttaylorr.com>
Subject: Re: [PATCH v2] am: Allow passing --no-verify flag
Date: Fri, 25 Nov 2022 18:41:37 +0100 [thread overview]
Message-ID: <Y4D+UU6l3YN9r9Xn@orome> (raw)
In-Reply-To: <xmqqilj8yir1.fsf@gitster.g>
[-- Attachment #1: Type: text/plain, Size: 3003 bytes --]
On Mon, Nov 21, 2022 at 02:33:06PM +0900, Junio C Hamano wrote:
> Thierry Reding <thierry.reding@gmail.com> writes:
>
> > From: Thierry Reding <treding@nvidia.com>
> >
> > The git-am --no-verify flag is analogous to the same flag passed to
> > git-commit. It bypasses the pre-applypatch and applypatch-msg hooks
> > if they are enabled.
> >
> > Signed-off-by: Thierry Reding <treding@nvidia.com>
> > ---
> > Changes in v2:
> > - add test to verify that the new option works
>
> > +-n::
> > +--no-verify::
> > + By default, the pre-applypatch and applypatch-msg hooks are run.
> > + When any of `--no-verify` or `-n` is given, these are bypassed.
> > + See also linkgit:githooks[5].
>
> I think the goal of this topic is to allow bypassing the checks made
> by these two hooks (and possibly future ones that validate the input
> to "am"), and there are at least two possible implementations to
> achieve that goal. You can still run the hook and ignore its
> failure exit, or you can skip running the hook and pretend as if
> hook succeeded.
>
> As it is documented that applypatch-msg is allowed to edit the
> message file to normalize the message, between the two, running the
> hook (to allow the hook to automatically edit the message) but
> ignoring its failure would be a more intuitive approach to "bypass"
> the check. If the option were called --no-hook or --bypass-hooks
> then it would be a different story, though.
>
> > assert(state->msg);
> > - ret = run_hooks_l("applypatch-msg", am_path(state, "final-commit"), NULL);
> > +
> > + if (!state->no_verify)
> > + ret = run_hooks_l("applypatch-msg", am_path(state, "final-commit"), NULL);
>
> And it seems that this took a less intuitive avenue of bypassing the
> hook completely. I am not 100% convinced that this is the better
> choice (but I am not convinced it is the worse one, either).
Thinking a bit more about this, if we let applypatch-msg run but ignore
failures and continue on to commit the result, wouldn't that potentially
allow committing garbage? I'm thinking about cases where applypatch-msg
may attempt to normalize the message and fails badly, leaving a partial
commit message or none at all.
The primary use-case where I'd like to use this new option for git am is
when the pre-applypatch hook fails and that has less of the risks
associated with applypatch-msg, so perhaps --no-verify should only apply
to pre-applypatch?
>
> > diff --git a/t/t4154-am-noverify.sh b/t/t4154-am-noverify.sh
> > new file mode 100755
> > index 000000000000..fbf45998243f
> > --- /dev/null
> > +++ b/t/t4154-am-noverify.sh
> > @@ -0,0 +1,60 @@
> > +#!/bin/sh
> > +
>
> It is surprising, and I am not enthused to see, that this needs an
> entirely new script.
>
> Don't we already have a script or two to test "am", among which the
> invocation of hooks is already tested?
I can move the tests to the corresponding sections in t/t4150-am.sh.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2022-11-25 17:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-19 0:50 [PATCH v2] am: Allow passing --no-verify flag Thierry Reding
2022-11-21 5:33 ` Junio C Hamano
2022-11-25 17:41 ` Thierry Reding [this message]
2022-11-27 1:27 ` Junio C Hamano
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=Y4D+UU6l3YN9r9Xn@orome \
--to=thierry.reding@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=me@ttaylorr.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.