From d80811b882ddce9e41136f6954be729fd852d5c4 Mon Sep 17 00:00:00 2001 From: Brad Fitzpatrick Date: Fri, 9 Oct 2026 14:50:31 +0000 Subject: [PATCH] version/mkversion: don't use os.DevNull for git config in tests Git for Windows 2.56.0 rejects GIT_CONFIG_GLOBAL=NUL with "unable to access 'NUL': Invalid argument" (git-for-windows/git#6449), breaking TestInfoFromEnvMatchesGit and TestInfoFromEnvPrecedence on Windows runners with the new git. Point them at an empty file instead. Updates git-for-windows/git#6449 Signed-off-by: Brad Fitzpatrick Change-Id: If2b9b6d29344b9280771e507d7d7e6c06f7ab9b0 --- version/mkversion/mkversion_env_test.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/version/mkversion/mkversion_env_test.go b/version/mkversion/mkversion_env_test.go index 72edb330e..0399b9025 100644 --- a/version/mkversion/mkversion_env_test.go +++ b/version/mkversion/mkversion_env_test.go @@ -17,12 +17,19 @@ import ( // the test on error. func gitIn(t *testing.T, dir string, args ...string) string { t.Helper() + // Use an empty file rather than os.DevNull, as Git for Windows 2.56.0 + // rejects "NUL" for GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM. + // See https://github.com/git-for-windows/git/issues/6449. + emptyConfig := filepath.Join(t.TempDir(), "gitconfig") + if err := os.WriteFile(emptyConfig, nil, 0644); err != nil { + t.Fatal(err) + } cmd := exec.Command("git", args...) cmd.Dir = dir cmd.Env = append(os.Environ(), "GIT_AUTHOR_NAME=t", "GIT_AUTHOR_EMAIL=t@t", "GIT_COMMITTER_NAME=t", "GIT_COMMITTER_EMAIL=t@t", - "GIT_CONFIG_GLOBAL="+os.DevNull, "GIT_CONFIG_SYSTEM="+os.DevNull, + "GIT_CONFIG_GLOBAL="+emptyConfig, "GIT_CONFIG_SYSTEM="+emptyConfig, ) out, err := cmd.CombinedOutput() if err != nil {