Re: [PATCH v7 2/3] maintenance: `git maintenance run` learned `--scheduler=<scheduler>`
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Jul 6, 2021, 19:56 UTC
- Message-ID
- <87h7h75hzz.fsf@evledraar.gmail.com>
- In-Reply-To
- <20210702142556.99864-3-lenaic@lhuard.fr>
On Fri, Jul 02 2021, Lénaïc Huard wrote:
Show 6 quoted lines
> + * ┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ > + * ┃ 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.
Show 29 quoted lines
> +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.
Show 6 quoted lines
> +#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).