Skip to content

git: Add agent auth helpers#76

Open
lox wants to merge 2 commits into
mainfrom
lox/agent-github-auth
Open

git: Add agent auth helpers#76
lox wants to merge 2 commits into
mainfrom
lox/agent-github-auth

Conversation

@lox

@lox lox commented Jun 6, 2026

Copy link
Copy Markdown
Owner

Agents currently inherit Git settings that can make commits or GitHub transport depend on interactive 1Password SSH approval. That blocks otherwise-ready work when a non-interactive shell cannot approve the signing or SSH-agent prompt.

This adds executable git-assume and git-github-auth helpers so agent shells can select both identity and GitHub transport explicitly. git-assume now works outside interactive zsh, disables signing for identities without a signing key, and writes worktree-local identity config when linked worktrees support it.

git-github-auth gh rewrites the current GitHub repo or worktree to use HTTPS through gh auth; git-github-auth ssh opts the repo back into SSH and 1Password. The transport helper uses repo-scoped URL rewrites so it applies to fetch and push, including shared pushurl values inherited by linked worktrees.

The global lox/* SSH rewrite is removed so HTTPS remotes stay on HTTPS unless a repo opts into SSH explicitly.

@lox lox marked this pull request as ready for review June 6, 2026 06:49
@lox lox force-pushed the lox/agent-github-auth branch from 6b4d99a to db2c311 Compare June 6, 2026 06:51

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6b4d99ae34

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/git-github-auth
Comment thread bin/git-github-auth Outdated
Comment thread bin/git-github-auth Outdated
@lox

lox commented Jun 6, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 507192d8af

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread bin/git-github-auth
Comment on lines +142 to +145
config_scope=()
if git_dir=$(git rev-parse --git-dir 2>/dev/null) &&
git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null) &&
[[ "$git_dir" != "$git_common_dir" ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve main worktree-local config scope

When extensions.worktreeConfig is enabled on the main worktree, Git reads config.worktree after .git/config and updates it via git config --worktree (git-worktree docs); this condition only selects --worktree for linked worktrees. Because the earlier git config --get-all remote.$remote.url also sees worktree-scoped values, running git-github-auth from the main worktree can copy a main-only remote or pushurl into shared .git/config, changing the remotes seen by other worktrees instead of just the current one.

Useful? React with 👍 / 👎.

Comment thread bin/git-github-auth
local repo_path
local target_url

git config --unset-all "$key" 2>/dev/null || true

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Remove inherited push URLs before adding replacements

When remote.<name>.pushurl is inherited from global or included config, this unset only edits the repository-local file by default (git-config docs), so the inherited SSH pushurl remains alongside the newly added HTTPS one. Git pushes to all defined pushurls (git-push docs), so git-github-auth gh can still attempt the original SSH/1Password push destination even after reporting that the repo was switched.

Useful? React with 👍 / 👎.

Comment thread bin/git-assume
Comment on lines +23 to +26
if git_dir=$(git rev-parse --git-dir 2>/dev/null) &&
git_common_dir=$(git rev-parse --git-common-dir 2>/dev/null) &&
[[ "$git_dir" != "$git_common_dir" ]] &&
[[ "$(git config --bool --get extensions.worktreeConfig 2>/dev/null)" == "true" ]]; then

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Write identity changes to main worktree config

When extensions.worktreeConfig is enabled on the main worktree, Git reads config.worktree after .git/config (git-worktree docs), but this condition only selects --worktree for linked worktrees. If the main worktree already has a worktree-scoped user.name, user.email, signing key, or commit.gpgsign, git-assume <identity> writes the new identity to shared .git/config while the existing config.worktree value still wins, so commits in that checkout continue using the old identity.

Useful? React with 👍 / 👎.

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