Skip to content

wip/core(git): opportunistic git fetch#11833

Draft
grouville wants to merge 7 commits intodagger:mainfrom
grouville:opportunistic-git
Draft

wip/core(git): opportunistic git fetch#11833
grouville wants to merge 7 commits intodagger:mainfrom
grouville:opportunistic-git

Conversation

@grouville
Copy link
Member

@grouville grouville commented Feb 10, 2026

Follow-up of git lazification, on top of #11560

For the hot path: dag.Git().Head().tree(), instead of always:

  1. ls-remote
  2. then fetch

We should be able to only fetch directly to avoid this unnecessary step. This has implications on the function caching, but discussion is open on that

This is an ugly solution still, but the aim is to assess the performance across the entire test suite in order to assess whether it's a worthwhile change

This lazifies the git API and makes resolution (`_resolve`) the only place where we touch remote state.

Pure, and auth/remote lookup only happens when we resolve them. Resolve paths (`tree`, `branches`, `tags`) run under `CachePerClient`. So, in one-shot CLI usage, auth is effectively checked once per command (same as `main`), while long-lived clients reuse the same resolved value within.

Cache identity is based on semantics:
1. *repo identity* includes access method (protocol + auth inputs) and remote snapshot (`ls-remote`), so auth contexts do not collide and pushes invalidate cache.
2. *ref identity* is based on resolved ref target (name + commit) on top of repo identity.
3. *tree identity* is based on checkout shape (`commit/depth/discardGitDir`) after resolve, so equivalent content trees can be shared without skipping auth checks.

Safeguard: any path that resolves git state (and therefore evaluates auth or remote state) MUST go through a `CachePerClient` resolve boundary, now

Signed-off-by: Guillaume de Rouville <[email protected]>
After dagger#11828, lazy git resolution routes SSH auth through host._sshAuthSocket. When SSH_AUTH_SOCK is missing, that surfaced a host-level error string and regressed cross-session auth-leak expectations. Keep the host cause typed and map it back to the existing git-facing auth error in repo.__resolve so behavior stays stable without changing cache identity semantics.

Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
Signed-off-by: Guillaume de Rouville <[email protected]>
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