Re: [PATCH v7 2/3] maintenance: `git maintenance run` learned `--scheduler=<scheduler>`
From: Ævar Arnfjörð Bjarmason <hidden>
Date: 2021-07-06 20:01:42
On Fri, Jul 02 2021, Lénaïc Huard wrote:
quoted hunk ↗ jump to hunk
+ * ┏━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓ + * ┃ 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.
quoted hunk ↗ jump to hunk
+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.
quoted hunk ↗ jump to hunk
+#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).