git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 3/3] config: learn the "hostname:" includeIf condition

From
Junio C Hamano <gitster@pobox.com>
Date
Oct 12, 2026, 19:24 UTC
Message-ID
<xmqqa4oi67tx.fsf@gitster.g>
In-Reply-To
<20261012015846.2649843-4-bellacaselli20@gmail.com>
Isabella Caselli <bellacaselli20@gmail.com> writes:
Show 24 quoted lines
> +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.

Previous: Isabella CaselliNext: Jeff King
Message 14 of 15 in “hostname: includeIf condition — anyone already working on this?”
  1. Isabella CaselliSep 28, 2026
  2. Jeff KingSep 29, 2026
  3. Ignacio EncinasSep 29, 2026
  4. Jeff KingSep 29, 2026
  5. Junio C HamanoSep 29, 2026
  6. Isabella CaselliOct 2, 2026
  7. 0/3 Add hostname condition to includeIfIsabella Caselli, Oct 12, 2026
  8. 1/3 var: add GIT_HOSTNAMEIsabella Caselli, Oct 12, 2026
  9. 2/3 t6500: get hostname from "git var"Isabella Caselli, Oct 12, 2026
  10. Junio C HamanoOct 12, 2026
  11. Isabella CaselliOct 13, 2026
  12. Junio C HamanoOct 13, 2026
  13. 3/3 config: learn the "hostname:" includeIf conditionIsabella Caselli, Oct 12, 2026
  14. Junio C HamanoOct 12, 2026
  15. Jeff KingOct 14, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.