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

[PATCH 0/3] Add hostname condition to includeIf

From
ICIsabella Caselli <bellacaselli20@gmail.com>
Date
Oct 12, 2026, 01:58 UTC
Message-ID
<20261012015846.2649843-1-bellacaselli20@gmail.com>
In-Reply-To
<CAK4AdTSnaAOk649a0GLe1M9C+cYuDa0Nwo54=HT47R53Q4ZdWw@mail.gmail.com>

This series adds a "hostname:" condition to includeIf, allowing a configuration file to be included only on machines whose hostname matches a pattern. It also adds GIT_HOSTNAME to "git var", so users can see which hostname Git uses for matching.

The series is based on Ignacio Encinas's v3 from March 2024 [1]. Ignacio dropped the series and agreed to let me give it a try, so I am sending it as a new series. The "hostname:" patch retains his work and credits him with Based-on-patch-by.

Changes since Ignacio's v3:
 - Drop "test-tool xgethostname". Eric pointed out that exposing the
   hostname to users would make the helper unnecessary, and suggested
   adding GIT_HOSTNAME to "git var", which I agree is the best way to
   make this information available to users. Patch 1 adds it, and the
   tests use it instead of the helper.
 - Make "git var -l" omit GIT_HOSTNAME when the hostname cannot be
   determined, rather than failing, as Jeff suggested.
 - Make t6500 use "git var GIT_HOSTNAME || echo unknown", as Jeff
   suggested and Junio agreed.
 - Document that the hostname may be short or fully qualified, using
   Jeff's proposed wording, and point to "git var GIT_HOSTNAME"
   instead of gethostname(2), which Eric noted would not be helpful
   to users.
 - Use xmemdupz() in include_by_hostname(), as Jeff suggested.
 - In t1305, read the hostname into a variable before each
   here-document, so that failures are not silently ignored, as
   Junio pointed out.

One open question is case sensitivity. Matching is case-sensitive, like "onbranch:", so "hostname:MyHost" would not match a machine that reports "myhost", even though DNS names are case-insensitive. Keeping it case-sensitive seems reasonable to me, but I was not sure. Should it stay as is, ignore case, or have a "hostname/i:" variant, like "gitdir/i:"?

[1] https://lore.kernel.org/git/20240319183722.211300-1-ignacio@iencinas.com/
Isabella Caselli (3):
  var: add GIT_HOSTNAME
  t6500: get hostname from "git var"
  config: learn the "hostname:" includeIf condition
 Documentation/config.adoc  | 14 ++++++++++++
 Documentation/git-var.adoc |  5 +++++
 builtin/var.c              | 13 +++++++++++
 config.c                   | 17 +++++++++++++++
 t/t0007-git-var.sh         |  5 +++++
 t/t1305-config-include.sh  | 44 ++++++++++++++++++++++++++++++++++++++
 t/t6500-gc.sh              |  2 +-
 7 files changed, 99 insertions(+), 1 deletion(-)
base-commit: 5a7d1e8045ce66c908f62598e26cbb8df7b39a90
-- 
2.43.0
Previous: Isabella CaselliNext: Isabella Caselli
Message 7 of 14 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

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.