Skip to content

tests/functional: isolate git tests from host signing config#15094

Merged
Ericson2314 merged 1 commit intoNixOS:masterfrom
amaanq:git-signing-isolation
Jan 27, 2026
Merged

tests/functional: isolate git tests from host signing config#15094
Ericson2314 merged 1 commit intoNixOS:masterfrom
amaanq:git-signing-isolation

Conversation

@amaanq
Copy link
Member

@amaanq amaanq commented Jan 27, 2026

Motivation

Currently, tests fail when the host system has commit.gpgsign or tag.gpgsign enabled at the system level (in my case, a custom path located at /etc/git/config), since the signing key is unavailable in the test sandbox.

Context

The tests set HOME=$TEST_HOME to isolate themselves, which bypasses the user-level git config (~/.gitconfig). However, if a user sets the system-level config via GIT_CONFIG_GLOBAL or GIT_CONFIG_SYSTEM, it still applies, causing commits to fail when signing is enabled there.

In this PR, I explicitly set GIT_CONFIG_GLOBAL and GIT_CONFIG_SYSTEM to /dev/null so that the user's system config is never read from or written to. I've also replaced git config --global protocol.file.allow always with GIT_CONFIG_* environment variables to avoid writing to /dev/null.


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@amaanq amaanq requested a review from edolstra as a code owner January 27, 2026 03:04
@github-actions github-actions bot added the with-tests Issues related to testing. PRs with tests have some priority label Jan 27, 2026
@amaanq amaanq force-pushed the git-signing-isolation branch from 5193f58 to 9dfa62c Compare January 27, 2026 03:05
@Ericson2314
Copy link
Member

Instead of trying to cancel out specific settings, what if we define GIT_CONFIG_SYSTEM / GIT_CONFIG_GLOBAL to prevent the tests from reading the system config entirely?

@amaanq amaanq force-pushed the git-signing-isolation branch from 9dfa62c to 2c35a5f Compare January 27, 2026 15:29
@amaanq
Copy link
Member Author

amaanq commented Jan 27, 2026

Instead of trying to cancel out specific settings, what if we define GIT_CONFIG_SYSTEM / GIT_CONFIG_GLOBAL to prevent the tests from reading the system config entirely?

Yeah that's actually better. We'd still need the env variables for setting protocol.file.allow to avoid writing to a system config though.

Currently, tests fail when the host system has `commit.gpgsign` or
`tag.gpgsign` enabled at the system level (in my case, a custom path
located at `/etc/git/config`), since the signing key is unavailable in
the test sandbox.

The tests set `HOME=$TEST_HOME` to isolate themselves, which bypasses
the user-level git config (`~/.gitconfig`). However, if a user sets the
system-level config via `GIT_CONFIG_GLOBAL` or `GIT_CONFIG_SYSTEM`, it
still applies, causing commits to fail when signing is enabled there.

In this PR, I explicitly set `GIT_CONFIG_GLOBAL` and `GIT_CONFIG_SYSTEM`
to `/dev/null` so that the user's system config is never read from or
written to. I've also replaced `git config --global protocol.file.allow
always` with `GIT_CONFIG_*` environment variables to avoid writing to
`/dev/null`.
@amaanq amaanq force-pushed the git-signing-isolation branch from 2c35a5f to ac9682c Compare January 27, 2026 17:32
@Ericson2314 Ericson2314 added this pull request to the merge queue Jan 27, 2026
Merged via the queue into NixOS:master with commit 9e9b6d4 Jan 27, 2026
15 checks passed
@amaanq amaanq deleted the git-signing-isolation branch January 28, 2026 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants