Re: [PATCH v2 1/7] run-command: add preliminary support for multiple hooks

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Hannes,

On Thu, 16 May 2019, Johannes Sixt wrote:

> 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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux