]> git.ipfire.org Git - thirdparty/git.git/commit
send-email: try to get fqdn by running hostname -f on Linux and macOS
authorAditya Garg <gargaditya08@live.com>
Mon, 12 May 2025 08:11:19 +0000 (08:11 +0000)
committerJunio C Hamano <gitster@pobox.com>
Wed, 14 May 2025 00:14:29 +0000 (17:14 -0700)
commit9c9f8849a2a5ca058e8a9a1dfd6c9c925533e581
tree222da3ca773160552027b17763103fa612f08a91
parent6f84262c44a89851c3ae5a6e4c1a9d06b2068d75
send-email: try to get fqdn by running hostname -f on Linux and macOS

`hostname` is a popular command available on both Linux and macOS. As
per the man-page[1], `hostname -f` command returns the fully qualified
domain name (FQDN) of the system. The current Net::Domain perl module
being used in the script for the same has been quite unrealiable in many
cases. Thankfully, we now have a better check for valid_fqdn, which does
reject the invalid FQDNs given by this module properly, but at the same
time, it will result in a fallback to 'localhost.localdomain' being
used. `hostname -f` has been quite reliable (probably even more reliable
than the Net::Domain module) and before falling back to
'localhost.localdomain', we should try to use it. Interestingly, the
`hostname` command is actually used by perl modules like Net::Domain[2]
and Sys::Hostname[3] to get the hostname. So, lets give `hostname -f` a
chance as well!

[1]: https://man7.org/linux/man-pages/man1/hostname.1.html
[2]: https://github.com/Perl/perl5/blob/blead/cpan/libnet/lib/Net/Domain.pm#L88
[3]: https://github.com/Perl/perl5/blob/blead/ext/Sys-Hostname/Hostname.pm#L93

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
git-send-email.perl