fix(agent): forward repo-local git identity into docker sandbox by radim10 · Pull Request #76 · stashbase/cli · GitHub
Skip to content

fix(agent): forward repo-local git identity into docker sandbox - #76

Merged
radim10 merged 3 commits into
masterfrom
fix/docker-sandbox-repo-git-identity
Oct 17, 2026
Merged

radim10 merged 3 commits into
masterfrom
fix/docker-sandbox-repo-git-identity

Conversation

@radim10

@radim10 radim10 commented Oct 17, 2026

Copy link
Copy Markdown
Member

Problem

Docker sandbox runs forward the host's git identity as GIT_AUTHOR_* / GIT_COMMITTER_* env vars, read with git config --global. Inside the container those env vars beat every config file. So a repo that sets its own user.name / user.email (for example a work email) still got commits signed with the global identity.

Fix

host_git_config now runs git -C <workdir> config --get <key>. Git resolves it the same way git commit would on the host: worktree config first, then repo-local, then global (including includeIf sections that match the workdir), then system. --worktree runs pick up the main repo's identity. Identity set in a profile's env vars still wins, and only the identity is forwarded, never the host .gitconfig itself.

Tests

  • The two existing forwarding tests used to skip on machines with no global identity. They now use a temporary repo with its own identity, so they always run.
  • New lookup tests use an isolated global config (GIT_CONFIG_GLOBAL with GIT_CONFIG_NOSYSTEM), so they never read the real gitconfig. They cover repo-local beating global, falling back to global, includeIf gitdir:, nothing configured, and a worktree reading the main repo's identity.

cargo test passes in full (625 + 25 + 33), and clippy reports no new warnings.

Resolve user.name/user.email against the run's working directory instead
of --global, so a repo-local identity (or a matching includeIf) wins over
the global one. The forwarded GIT_* env vars override every config file
in the container, so a global-only lookup silently masked repo config.
Run the config lookup against an isolated global config (GIT_CONFIG_GLOBAL,
GIT_CONFIG_NOSYSTEM) to cover repo-local precedence, global fallback,
includeIf matching the workdir, nothing configured, and worktrees picking
up the main repo's identity.
@radim10 radim10 self-assigned this Oct 17, 2026
Pass git forward-slash paths without the \\?\ verbatim prefix that
canonicalize returns on Windows, since gitconfig values treat backslashes
as escapes, and match gitdir case-insensitively.
@radim10
radim10 merged commit c954198 into master Oct 17, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant