From: Junio C Hamano <gitster@pobox.com>
To: Isabella Caselli <bellacaselli20@gmail.com>
Cc: git@vger.kernel.org, Jeff King <peff@peff.net>,
Eric Sunshine <sunshine@sunshineco.com>,
Ignacio Encinas <ignacio@iencinas.com>
Subject: Re: [PATCH 2/3] t6500: get hostname from "git var"
Date: Mon, 12 Oct 2026 12:20:41 -0700 [thread overview]
Message-ID: <xmqqecdu67zq.fsf@gitster.g> (raw)
In-Reply-To: <20261012015846.2649843-3-bellacaselli20@gmail.com> (Isabella Caselli's message of "Sun, 11 Oct 2026 22:58:45 -0300")
Isabella Caselli <bellacaselli20@gmail.com> writes:
> The test "background auto gc respects lock for all operations" simulates
> a concurrent gc by writing our shell's pid and hostname to "gc.pid".
> It gets the hostname from the "hostname" command, falling back to
> "unknown" if the command fails.
>
> "git gc" gets its hostname from the system and only checks whether the
> pid is alive if the two hostnames match. Otherwise, it assumes the
> lock belongs to a gc running on another machine. Since the test passes
> in either case, a missing "hostname" command or a mismatch between
> its output and the system hostname can cause the test to silently
> exercise the wrong case.
"exercise the wrong case", meaning... where hostname(1) output is
different from "git var GIT_HOSTNAME" (aka xgethostname()), we would
have written bogus name in .git/gc.pid file, simulating the case where
gc.pid was written by a process running on a different machine.
What is the implications of doing so?
>
> Use "git var GIT_HOSTNAME" to get the same hostname as "git gc".
> Keep the "unknown" fallback, which is also used by "git gc" when it
> cannot determine the hostname.
>
> Helped-by: Jeff King <peff@peff.net>
> Signed-off-by: Isabella Caselli <bellacaselli20@gmail.com>
> ---
> t/t6500-gc.sh | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/t/t6500-gc.sh b/t/t6500-gc.sh
> index a7142ab815..f928089bf0 100755
> --- a/t/t6500-gc.sh
> +++ b/t/t6500-gc.sh
> @@ -413,7 +413,7 @@ test_expect_success 'background auto gc respects lock for all operations' '
>
> # now fake a concurrent gc that holds the lock; we can use our
> # shell pid so that it looks valid.
> - hostname=$(hostname || echo unknown) &&
> + hostname=$(git var GIT_HOSTNAME || echo unknown) &&
> shell_pid=$$ &&
> if test_have_prereq MINGW && test -f /proc/$shell_pid/winpid
> then
next prev parent reply other threads:[~2026-10-12 19:20 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-28 23:43 hostname: includeIf condition — anyone already working on this? Isabella Caselli
2026-09-29 1:44 ` Jeff King
2026-09-29 12:14 ` Ignacio Encinas
2026-09-29 18:28 ` Jeff King
2026-09-29 19:55 ` Junio C Hamano
2026-10-02 1:52 ` Isabella Caselli
2026-10-12 1:58 ` [PATCH 0/3] Add hostname condition to includeIf Isabella Caselli
2026-10-12 1:58 ` [PATCH 1/3] var: add GIT_HOSTNAME Isabella Caselli
2026-10-12 1:58 ` [PATCH 2/3] t6500: get hostname from "git var" Isabella Caselli
2026-10-12 19:20 ` Junio C Hamano [this message]
2026-10-13 1:14 ` Isabella Caselli
2026-10-13 1:43 ` Junio C Hamano
2026-10-12 1:58 ` [PATCH 3/3] config: learn the "hostname:" includeIf condition Isabella Caselli
2026-10-12 19:24 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqecdu67zq.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=bellacaselli20@gmail.com \
--cc=git@vger.kernel.org \
--cc=ignacio@iencinas.com \
--cc=peff@peff.net \
--cc=sunshine@sunshineco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox