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

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

From
Jeff King <peff@peff.net>
Date
Mar 18, 2024, 08:17 UTC
Message-ID
<20240318081722.GA602575@coredump.intra.peff.net>
In-Reply-To
<xmqqo7bem7o8.fsf@gitster.g>
On Sat, Mar 16, 2024 at 10:02:31AM -0700, Junio C Hamano wrote:
Show 11 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Do we need to define "hostname" in more detail here? Specifically, I'm
> > wondering whether the result will be a FQDN or not (i.e., the output of
> > "hostname" vs "hostname -f"). Looking at the code I think it will just
> > be the short name returned. That's probably OK, but it may be worth
> > documenting.
> 
> That was my first reaction but there are places where "hostname"
> already gives a name that is not "short" at all, without being
> invoked with "-f".

Thanks, that was the vague buzzing in the back of my head that led to my first comment. It has been a while since I've dealt with this, but I think in some circles it is a holy war akin to tabs vs spaces. A quick search shows I am not alone:

  https://serverfault.com/questions/331936/setting-the-hostname-fqdn-or-short-name
So I think we probably need to say something like:
  Depending on how your system is configured, the hostname used for
  matching may be short (e.g., "myhost") or a fully qualified domain
  name ("myhost.example.com").
> I think the most honest answer we can give in the documentation is
> that we use what gethostname() [*] gives.

That is honest, but I wonder if it is very useful to most users, as they cannot easily see what it returns. It's tempting to give an extra note like this tacked on to what I said above:

  You can run the hostname(1) tool to see which hostname your system
  uses.

But I'm not sure that it is available everywhere (especially Windows). I guess we could provide "git config --show-hostname-for-includes" or something, but that feels like overkill.

Maybe just the "Depending..." note is enough, and people who are interested in hostname conditionals hopefully know enough to dig further on their system. What I think we want to avoid is saying nothing, and then somebody tries "foo.example.com", finds that it doesn't work, and gets confused with no hints about why.

I guess yet another alternative is to try to qualify the name ourselves using getaddrinfo(), either unconditionally or if the hostname doesn't contain a ".". That may involve a DNS lookup, though (if your hostname isn't in /etc/hosts).

-Peff
Previous: rsbecker@nexbridge.comNext: Taylor Blau
Message 20 of 51 in “Add hostname condition to includeIf”
  1. 0/1 Add hostname condition to includeIfIgnacio Encinas, Mar 7, 2024
  2. 1/1 config: learn the "hostname:" includeIf conditionIgnacio Encinas, Mar 7, 2024
  3. Junio C HamanoMar 7, 2024
  4. Ignacio Encinas RubioMar 9, 2024
  5. Junio C HamanoMar 9, 2024
  6. 0/1 Add hostname condition to includeIfIgnacio Encinas, Mar 9, 2024
  7. 1/1 config: learn the "hostname:" includeIf conditionIgnacio Encinas, Mar 9, 2024
  8. Junio C HamanoMar 10, 2024
  9. Ignacio Encinas RubioMar 10, 2024
  10. Junio C HamanoMar 11, 2024
  11. Ignacio Encinas RubioMar 13, 2024
  12. Jeff KingMar 16, 2024
  13. Ignacio Encinas RubioMar 16, 2024
  14. Taylor BlauMar 16, 2024
  15. Ignacio Encinas RubioMar 16, 2024
  16. Junio C HamanoMar 16, 2024
  17. rsbecker@nexbridge.comMar 16, 2024
  18. Ignacio Encinas RubioMar 16, 2024
  19. rsbecker@nexbridge.comMar 16, 2024
  20. Jeff KingMar 18, 2024
  21. Taylor BlauMar 16, 2024
  22. Ignacio Encinas RubioMar 16, 2024
  23. 0/2 Add hostname condition to includeIfIgnacio Encinas, Mar 19, 2024
  24. 1/2 t: add a test helper for getting hostnameIgnacio Encinas, Mar 19, 2024
  25. Junio C HamanoMar 19, 2024
  26. Jeff KingMar 19, 2024
  27. Junio C HamanoMar 19, 2024
  28. Jeff KingMar 19, 2024
  29. Junio C HamanoMar 19, 2024
  30. Chris TorekMar 21, 2024
  31. Jeff KingMar 19, 2024
  32. 2/2 config: learn the "hostname:" includeIf conditionIgnacio Encinas, Mar 19, 2024
  33. Junio C HamanoMar 19, 2024
  34. Jeff KingMar 19, 2024
  35. Ignacio Encinas RubioMar 19, 2024
  36. Eric SunshineMar 19, 2024
  37. Junio C HamanoMar 19, 2024
  38. Eric SunshineMar 19, 2024
  39. Jeff KingMar 20, 2024
  40. Eric SunshineMar 20, 2024
  41. Eric SunshineMar 20, 2024
  42. Chris TorekMar 20, 2024
  43. Eric SunshineMar 20, 2024
  44. Jeff KingMar 20, 2024
  45. Junio C HamanoMar 20, 2024
  46. Dirk GoudersMar 19, 2024
  47. rsbecker@nexbridge.comMar 19, 2024
  48. Dirk GoudersMar 19, 2024
  49. rsbecker@nexbridge.comMar 19, 2024
  50. Junio C HamanoMar 19, 2024
  51. Ignacio Encinas RubioMar 19, 2024

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.