[PATCH v2 2/3] t6500: get hostname from "git var"
- From
- Isabella Caselli <bellacaselli20@gmail.com>
- Date
- Oct 15, 2026, 10:58 UTC
- Message-ID
- <20261015105859.3184108-3-bellacaselli20@gmail.com>
- In-Reply-To
- <20261015105859.3184108-1-bellacaselli20@gmail.com>
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" only checks whether the pid in "gc.pid" is alive if the recorded hostname matches its own. If the hostnames differ, it assumes the lock belongs to a gc running on another machine and skips the pid check. Since the test passes in either case, it may pass without checking whether "git gc" detects a running process on the same machine.
Use "git var GIT_HOSTNAME" to get the same hostname as "git gc". Keep the "unknown" fallback, which "git gc" also uses 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
-- 2.43.0