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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Mar 16, 2024 at 10:02:31AM -0700, Junio C Hamano wrote:

> Jeff King <peff@xxxxxxxx> 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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux