All of lore.kernel.org
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste.net>
To: Duy Nguyen <pclouds@gmail.com>
Cc: "Git Mailing List" <git@vger.kernel.org>,
	"Jeff King" <peff@peff.net>,
	"Johannes Schindelin" <Johannes.Schindelin@gmx.de>,
	"Junio C Hamano" <gitster@pobox.com>,
	"Johannes Sixt" <j6t@kdbg.org>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
	"Phillip Wood" <phillip.wood123@gmail.com>,
	"Jonathan Nieder" <jrnieder@gmail.com>
Subject: Re: [PATCH v2 6/7] config: allow configuration of multiple hook error behavior
Date: Wed, 15 May 2019 23:10:17 +0000	[thread overview]
Message-ID: <20190515231017.GM7458@genre.crustytoothpaste.net> (raw)
In-Reply-To: <CACsJy8BN32Jm62MQPLsRwKST8DDNZ7NxnJbsqBO3PJ0K2qU-Ng@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 3178 bytes --]

On Tue, May 14, 2019 at 08:20:10PM +0700, Duy Nguyen wrote:
> On Tue, May 14, 2019 at 7:24 AM brian m. carlson
> <sandals@crustytoothpaste.net> wrote:
> >
> > There are a variety of situations in which a user may want an error
> > behavior for multiple hooks other than the default. Add a config option,
> > hook.<name>.errorBehavior to allow users to customize this behavior on a
> 
> An alternative name is onError, probably more often used for event
> callbacks. But I don't know, maybe errorBehavior is actually better.

I'm going to use "errorStrategy", since we already have
submodule.alternateErrorStrategy.

> > per-hook basis. Provide options for the default behavior (exiting
> 
> should we fall back to hook.errorBehavior? That allows people to set
> global policy, then customize just a small set of weird hooks.

Sure, that sounds good.

> maybe stop-on-first-error (or if you go with the "onError" name, I
> think "stop" is enough). I know "stop on/after first hook" does not
> really make any sense when you think about it. Maybe stop-on-first is
> sufficient.
> 
> I was going to suggest strcasecmp. But core.whitespace (also has
> multiple-word-values) already sets a precedent on strcmp. I think
> we're good. Or mostly good, I don't know, we still accept False, false
> and FALSE.

I think with errorStrategy, "stop" is fine. Simpler is better.

I literally picked what Peff had suggested in his email (mostly because
I'm terrible at naming things), and I don't get the impression he spent
a great deal of time analyzing the ins and outs of the names before
sending. I could be wrong, though.

> > +                       behavior = HOOK_ERROR_STOP_ON_FIRST;
> 
> This is basically the logical "and" behavior in a C expression. Which
> makes me think if anybody's crazy enough to need the "or" counterpart
> (i.e. run hooks, expect failure, keep going until the first success).
> 
> I guess it's a crazy mode. We should not care about until a real use
> case shows up.

Yeah, I think that's unlikely to be the case. Nothing prevents us from
adding it later.

> > +               else if (!strcmp(value, "report-any-error"))
> 
> I couldn't guess based on this name alone, whether we continue or stop
> after the reporting part. The 7/7 document makes it clear though. So
> all good.

I'm open to hearing better suggestions if anyone has any.

> > diff --git a/run-command.c b/run-command.c
> > index 191d6f6f7e..70fb19a55b 100644
> > --- a/run-command.c
> > +++ b/run-command.c
> > @@ -1308,6 +1308,8 @@ int async_with_fork(void)
> >  #endif
> >  }
> >
> > +struct string_list hook_error_behavior = STRING_LIST_INIT_NODUP;
> 
> Maybe stick this in 'struct repository'. I know most config variables
> are still global. But I think we have to move/reorganize them at some
> point. Most may end up in 'struct repository'.

Okay, sounds fine.

> > +                       default:
> > +                               BUG("unknown hook error behavior");
> 
> maybe BUG(".. behavior %d", behavior);

Sure.
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

  reply	other threads:[~2019-05-15 23:10 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-14  0:23 [PATCH v2 0/7] Multiple hook support brian m. carlson
2019-05-14  0:23 ` [PATCH v2 1/7] run-command: add preliminary support for multiple hooks brian m. carlson
2019-05-14 12:46   ` Duy Nguyen
2019-05-15 22:27     ` brian m. carlson
2019-05-29  2:18       ` brian m. carlson
2019-05-14 15:12   ` Johannes Schindelin
2019-05-15 22:44     ` brian m. carlson
2019-05-16 19:11       ` Johannes Sixt
2019-05-17 20:31         ` Johannes Schindelin
2019-05-14  0:23 ` [PATCH v2 2/7] builtin/receive-pack: add " brian m. carlson
2019-05-14  0:23 ` [PATCH v2 3/7] rebase: " brian m. carlson
2019-05-14 12:56   ` Duy Nguyen
2019-05-14 17:58     ` Johannes Sixt
2019-05-15 22:55     ` brian m. carlson
2019-05-16 10:29       ` Duy Nguyen
2019-05-14  0:23 ` [PATCH v2 3/7] sequencer: " brian m. carlson
2019-05-14  0:23 ` [PATCH v2 4/7] builtin/worktree: add support for multiple post-checkout hooks brian m. carlson
2019-05-14  0:23 ` [PATCH v2 5/7] transport: add support for multiple pre-push hooks brian m. carlson
2019-05-14  0:23 ` [PATCH v2 6/7] config: allow configuration of multiple hook error behavior brian m. carlson
2019-05-14 13:20   ` Duy Nguyen
2019-05-15 23:10     ` brian m. carlson [this message]
2019-05-16  5:08       ` Jeff King
2019-05-16  5:02   ` Jeff King
2019-05-16 17:19     ` brian m. carlson
2019-05-16 21:52       ` Jeff King
2019-05-14  0:23 ` [PATCH v2 7/7] docs: document multiple hooks brian m. carlson
2019-05-14 13:38   ` Duy Nguyen
2019-05-14  0:51 ` [PATCH v2 0/7] Multiple hook support Jonathan Nieder
2019-05-14  1:59   ` brian m. carlson
2019-05-14  2:26     ` Jonathan Nieder
2019-05-16  0:42       ` brian m. carlson
2019-05-16  0:51         ` Jonathan Nieder
2019-05-16  4:51     ` Jeff King
2019-05-14 13:30 ` Duy Nguyen

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=20190515231017.GM7458@genre.crustytoothpaste.net \
    --to=sandals@crustytoothpaste.net \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=jrnieder@gmail.com \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=phillip.wood123@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.