Re: [PATCH v2 1/1] config: learn the "hostname:" includeIf condition
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Mar 10, 2024, 16:59 UTC
- Message-ID
- <xmqqy1aqvx9n.fsf@gitster.g>
- In-Reply-To
- <20240309181828.45496-2-ignacio@iencinas.com>
Ignacio Encinas <ignacio@iencinas.com> writes:
> +test_expect_success 'conditional include, hostname' ' > + cat >>.git/config <<-EOF && > + [includeIf "hostname:$(hostname)a"]
This unconditionally runs the $(hostname) command assuming it exists everywhere, but
$ git grep '$(hostname' t/
t/t6500-gc.sh: hostname=$(hostname || echo unknown) &&tells us that we should be prepared to meet a platform where such a command does not exist.
I have a feeling that it is better done with a test prerequisite than hardcoded "unknown", as xgethostname() at C level may come up with some random string but it is not guaranteed to be "unknown".
Perhaps have one instance of this before these added tests
test_lazy_prereq WORKING_HOSTNAME ' hostname >/dev/null 2>&1 '
and then start them with
test_expect_success WORKING_HOSTNAME 'hostname: includeIf' ' ... '
or something? Others may think of a better way to make sure this test does not cause false failures on platforms only because they lack working hostname(1) but have a working gethostname(2) and their xgethostname() may be working fine.
Thanks.