Re: [PATCH v2 1/7] run-command: add preliminary support for multiple hooks
- From
Johannes Schindelin <johannes.schindelin@gmx.de>
- Date
- May 17, 2019, 20:31 UTC
- Message-ID
- <nycvar.QRO.7.76.6.1905172227200.46@tvgsbejvaqbjf.bet>
- In-Reply-To
- <91532c2d-7536-6e15-728b-bd18256b2ef3@kdbg.org>
Hi Hannes,
On Thu, 16 May 2019, Johannes Sixt wrote:
Show 30 quoted lines
> Am 16.05.19 um 00:44 schrieb brian m. carlson:
> > On Tue, May 14, 2019 at 05:12:39PM +0200, Johannes Schindelin wrote:
> >> On Tue, 14 May 2019, brian m. carlson wrote:
> >>> +/*
> >>> + * Return 1 if a hook exists at path (which may be modified) using access(2)
> >>> + * with check (which should be F_OK or X_OK), 0 otherwise. If strip is true,
> >>> + * additionally consider the same filename but with STRIP_EXTENSION added.
> >>> + * If check is X_OK, warn if the hook exists but is not executable.
> >>> + */
> >>> +static int has_hook(struct strbuf *path, int strip, int check)
> >>> +{
> >>> + if (access(path->buf, check) < 0) {
> >>> + int err = errno;
> >>> +
> >>> + if (strip) {
> >>> +#ifdef STRIP_EXTENSION
> >>> + strbuf_addstr(path, STRIP_EXTENSION);
> >>> + if (access(path->buf, check) >= 0)
> >>> + return 1;
> >>> + if (errno == EACCES)
> >>> + err = errno;
> >>> +#endif
> >>> + }
> >>
> >> How about simply guarding the entire `if()`? It is a bit unusual to guard
> >> *only* the inside block ;-)
> >
> > I can make that change.
>
> But then we'll have an unused argument in some build configurations.That's a valid point.
Thanks, Dscho