From: Junio C Hamano Date: Mon, 12 Oct 2026 19:24:10 GMT Subject: Re: [PATCH 3/3] config: learn the "hostname:" includeIf condition Message-ID: In-Reply-To: <20261012015846.2649843-4-bellacaselli20@gmail.com> Isabella Caselli writes: > +static int include_by_hostname(const char *cond, size_t cond_len) > +{ > + int ret; > + char my_host[HOST_NAME_MAX + 1]; > + char *pattern; > + > + if (xgethostname(my_host, sizeof(my_host))) > + return 0; > + > + pattern = xmemdupz(cond, cond_len); > + ret = !wildmatch(pattern, my_host, 0); > + free(pattern); > + return ret; > +} > + > static int add_remote_url(const char *var, const char *value, > const struct config_context *ctx UNUSED, void *data) > { > @@ -411,6 +426,8 @@ static int include_condition_is_true(const struct key_value_info *kvi, > else if (skip_prefix_mem(cond, cond_len, "hasconfig:remote.*.url:", &cond, > &cond_len)) > return include_by_remote_url(inc, cond, cond_len); > + else if (skip_prefix_mem(cond, cond_len, "hostname:", &cond, &cond_len)) > + return include_by_hostname(cond, cond_len); Neat. With this include_condition_is_true() helper, adding such conditional inclusion is made very easy. Quite nice.