Skip to content

fix(daemon): ask git for remotes so Suggestions follow includes and insteadOf - #417

Merged
bRRRITSCOLD merged 3 commits into
mainfrom
fix/402-git-config-includes
Nov 24, 2026
Merged

bRRRITSCOLD merged 3 commits into
mainfrom
fix/402-git-config-includes

Conversation

@bRRRITSCOLD

@bRRRITSCOLD bRRRITSCOLD commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Closes #402

Suggestions now get a Pane folder's remotes by asking git directly, so includes, includeIf and url.<base>.insteadOf rewrites all apply. Before, the daemon read only the repo's own config file, so a remote that only those turn into a GitHub URL got no Suggestion.

Approach: ask git, fall back to the file reader

  • One process per folder: the daemon runs git -C <folder> remote -v once per Pane folder each time Suggestions are worked out (duplicate folders are collapsed first). The (fetch) lines give each remote's URL after git has applied every config file, include, includeIf and insteadOf rewrite. A single call covers both upstream and origin, and remote -v already applies insteadOf, so no ls-remote --get-url is needed.
  • How it runs: no shell, stdin/stderr null, and the daemon's own environment, so the user's system, global and included config apply. GIT_DIR, GIT_WORK_TREE and GIT_COMMON_DIR are removed so they can't point git at a different repo. It runs inside the existing spawn_blocking. A reader thread with recv_timeout kills git after 2 s.
  • Fallback: if git is missing, exits non-zero or times out, the daemon uses the previous reader, which reads the repo's config file directly. It is kept as remotes/file.rs and still handles repo discovery, worktrees and gitdir: files.
  • No cache: Suggestions are worked out only when something they depend on changes (a Pane opening, exiting or moving, a Link, a Repository or the sign-in) and on each read of the route, never per keystroke. A git call per Pane folder each time is cheap and never goes stale after a config edit.
  • Why not a hand-written parser: an earlier commit in this PR implemented git's config rules by hand (about 800 lines). This PR replaces it, because git's own answer is right by definition and its rules keep growing.

No route, field or message changed, so API_VERSION stays the same. Spec §3 Suggestions is rewritten.

Code

  • agentdeckd/src/suggestions/remotes/mod.rs: Git (program and timeout), repository_of (asks git first, reads the file on any failure), and pick.
  • remotes/git.rs: runs git remote -v with the timeout and parses its output, including a partial clone's [filter] suffix and remotes without a URL.
  • remotes/file.rs: the previous reader, unchanged apart from now returning the remote URLs.

Tests

  • Unit tests: parsing of git remote -v output; a git that isn't there; repository_of falling back to the config file when git can't start; the upstream/origin pick; the file reader's existing cases. No unit test runs a real git, so the developer's config can't leak in.
  • Daemon integration tests (7 new, in suggestions.rs git_config): each puts a Pane in a repo and expects the Suggestion:
    • Through real git: a global insteadOf, a repo insteadOf, a remote from an include.path file, a global includeIf gitdir: that matches one repo and not another, and a worktree whose main repo's remote is rewritten. Each fixture is also checked with real git remote get-url. The daemon runs with an isolated HOME/XDG_CONFIG_HOME and GIT_CONFIG_NOSYSTEM.
    • The fallback: a PATH without git, and a stub git that hangs (killed after 2 s).
  • cargo xtask ci passes locally.

🤖 Generated with Claude Code

bRRRITSCOLD and others added 3 commits November 23, 2026 19:21
Read the system and global git config files with the repo's, follow
include.path and includeIf (gitdir:, gitdir/i:, onbranch:), and rewrite
a remote's URL by the longest url.<base>.insteadOf, as git does, still
without a git process.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Spec §3: the config files read, includes and includeIf conditions,
insteadOf rewrites, and why the daemon reads them itself instead of
running git.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Replace the hand-written git config parser with one
`git -C <folder> remote -v` per Pane folder, which applies includes,
includeIf and insteadOf itself. No shell, the daemon's environment less
GIT_DIR/GIT_WORK_TREE/GIT_COMMON_DIR, killed after 2 s. When git is
missing, fails or times out, the repo's own config file is read as
before. Spec §3 says why and why nothing is cached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bRRRITSCOLD bRRRITSCOLD changed the title fix(daemon): follow git config includes and insteadOf for Suggestions fix(daemon): ask git for remotes so Suggestions follow includes and insteadOf Nov 24, 2026
@bRRRITSCOLD
bRRRITSCOLD merged commit fefbcce into main Nov 24, 2026
6 checks passed
@bRRRITSCOLD
bRRRITSCOLD deleted the fix/402-git-config-includes branch November 24, 2026 11:14
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.

Suggestions: follow git config includes and insteadOf rewrites

1 participant