Skip to content

fix: read git identity from XDG config when ~/.gitconfig exists#117

Merged
BrettKinny merged 1 commit into
mainfrom
fix/git-identity-xdg-fallback
Jul 19, 2026
Merged

fix: read git identity from XDG config when ~/.gitconfig exists#117
BrettKinny merged 1 commit into
mainfrom
fix/git-identity-xdg-fallback

Conversation

@BrettKinny

Copy link
Copy Markdown
Collaborator

Problem

On the Unraid tower, sqrbx-setup showed blank git name/email prompts and sqrbx-setup --list reported "(not set)" even though the identity was configured. Root cause: once gh auth setup-git creates ~/.gitconfig (holding only credential helpers), git config --global user.name reads that file alone and stops consulting ~/.config/git/config — the XDG file where setup records the identity. Reproduced on git 2.43 (in-Box) and 2.54.

Fix

  • setup.sh: new current_git_identity() helper — git config --global first (so a real ~/.gitconfig identity keeps precedence), falling back to a direct read of ~/.config/git/config; the rerun prefill uses it.
  • scripts/squarebox-setup.sh: same fallback in --list.
  • install.sh: same fallback for host-side seeding (a host with ~/.gitconfig plus an XDG-file identity hits the identical gotcha).
  • tests/test-provision-contract.sh: regression test with a credential-only ~/.gitconfig alongside an XDG identity, plus contract greps.

Verification

  • Full unit suite passes (27/27 in test-provision-contract.sh).
  • Fallback command verified against the actual broken state inside the tower's container — returns the configured identity.

🤖 Generated with Claude Code

Once gh auth setup-git creates ~/.gitconfig (credential helpers only),
`git config --global user.name` reads that file alone and never consults
~/.config/git/config, where setup records the identity. sqrbx-setup then
showed blank prompts instead of prefilled name/email, and --list reported
"(not set)" despite a configured identity.

Fall back to reading the XDG file directly in setup.sh, the sqrbx-setup
list view, and install.sh host-side seeding, keeping ~/.gitconfig
precedence when it does hold an identity. Add a regression test covering
a credential-only ~/.gitconfig alongside an XDG identity.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@BrettKinny
BrettKinny merged commit bb56f20 into main Jul 19, 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