Re: [PATCH v7 2/3] maintenance: `git maintenance run` learned `--scheduler=<scheduler>`

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

 



On Fri, Jul 02 2021, Lénaïc Huard wrote:

> + *     ┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
> + *     ┃ Input ┃                     Output                      ┃
> + *     ┃ *cmd  ┃ return code │       *cmd        │ *is_available ┃
> + *     ┣━━━━━━━╋━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━━━━━┿━━━━━━━━━━━━━━━┫
> + *     ┃ "foo" ┃    false    │ "foo" (unchanged) │  (unchanged)  ┃
> + *     ┗━━━━━━━┻━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━━━━━┷━━━━━━━━━━━━━━━┛

I wonder if we have developers for whom the non-ASCII here is an issue.

> +static int get_schedule_cmd(const char **cmd, int *is_available)
> +{
> +	char *item;
> +	char *testing = xstrdup_or_null(getenv("GIT_TEST_MAINT_SCHEDULER"));
> +
> +	if (!testing)
> +		return 0;
> +
> +	if (is_available)
> +		*is_available = 0;
> +
> +	for (item = testing;;) {
> +		char *sep;
> +		char *end_item = strchr(item, ',');
> +		if (end_item)
> +			*end_item = '\0';
> +
> +		sep = strchr(item, ':');
> +		if (!sep)
> +			die("GIT_TEST_MAINT_SCHEDULER unparseable: %s", testing);
> +		*sep = '\0';
> +
> +		if (!strcmp(*cmd, item)) {
> +			*cmd = sep + 1;
> +			if (is_available)
> +				*is_available = 1;
> +			UNLEAK(testing);
> +			return 1;
> +		}

This sort of code is much more pleseant to read and work with if you use
strbuf_split_buf(). This isn't performance sensitive, so a few more
allocations is fine.

> +#ifdef __APPLE__
> +	return 1;
> +#else
> +	return 0;
> +#endif
> +}

I see this is partially a pre-existing thing in the file, but we have an
__APPLE__ already in cache.h. Perhaps define a iLAUNCHCTL_AVAILABLE
there. See e.g. 62e5ee81a39 (read-cache.c: remove #ifdef NO_PTHREADS,
2018-11-03).




[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