IsPromisorRepo() caches the result via sync.Once, but the first call uses the provided…
- User
IsPromisorRepo() caches the result via sync.Once, but the first call uses the provided ctx for git config. If that ctx is already canceled or times out, cmd.Output() will fail and the function will cache false for the rest of the process, even when later calls have a valid context. Consider running the detection with a non-cancelable context (or only caching when the command succeeds / ctx isn’t canceled), so transient context errors don’t permanently force the non-promisor path.
Assistant· claude-opus-4-6
Good catch. Let me find the function.
Assistant· claude-opus-4-6
Now let me check the test file for existing tests.
Assistant· claude-opus-4-6
The fix: only cache the result when the command succeeds or the context wasn't the cause of failure. The simplest correct approach is to not use
sync.Onceand instead use a three-state atomic (unknown/true/false), only caching on success. But actually, the cleanest fix is to detach the context so it's never cancelable while still inheriting nothing dangerous.Let me think about this more carefully. The simplest fix that matches the suggestion: use
context.WithoutCancel(Go 1.21+) so the git command runs to completion regardless of the caller's context state.Assistant· claude-opus-4-6
Good,
context.WithoutCancelis available. However, the issue is subtler than just using a non-cancelable context — if we usecontext.WithoutCancel, the detection always runs to completion, but we lose the ability to respect timeouts. The real fix should be: only cache when the command succeeds or the context wasn't canceled.Actually, the simplest and most correct fix: use
context.WithoutCancelinside thesync.Once. The promisor detection is a quick localgit config --getcall — it doesn't need to be cancelable. This way the first call always gets a real answer.Assistant· claude-opus-4-6
Now let me add a test for the canceled-context scenario.
Assistant· claude-opus-4-6
All passing. The fix uses
context.WithoutCancel(ctx)inside thesync.Onceclosure so thegit config --getcall always runs to completion regardless of the caller's context state. Since this is a local, fast git config read, it doesn't need cancellation support, and the result will be correct for all subsequent callers.The new test verifies that passing an already-canceled context still correctly detects a promisor repo.
- User
IsPromisorRepo() runs git config --get extensions.partialClone without --local, so a user/global gitconfig setting could incorrectly mark every repo as promisor. Using git config --local --get extensions.partialClone keeps detection scoped to the repository config and avoids false positives (and makes tests less environment-dependent).
PartialCloneFilterArgsWithDepth()’s comment says it returns args for “tree-only fetches”, but for non-promisor repos it returns only --depth=1, which will fetch blobs for the tip commit. Please update the doc comment to reflect that non-promisor repos will do a shallow (not treeless) fetch, or adjust the implementation to match the comment.
The doc comment for FetchMetadataBranch() says the fetch is treeless (--filter=blob:none), but this change now uses PartialCloneFilterArgs(), which will use --depth=1 (and no filter) for non-promisor repos. Please update the function comment to match the new behavior so readers don’t assume blobs are always filtered.
FetchMetadataTreeOnly()’s comment currently states it fetches with --depth=1 --filter=blob:none, but PartialCloneFilterArgsWithDepth() omits the filter for non-promisor repos. Please update the comment (or rename the function) to avoid claiming the fetch is always treeless.
Assistant· claude-opus-4-6
Let me find all the relevant functions and their comments.
Assistant· claude-opus-4-6
Now let me read the full function bodies for the ones I need to update.
Assistant· claude-opus-4-6
Now let me read the
PartialCloneFilterArgsfunctions again for context and also check ifFetchV2MainRefneeds updating.Assistant· claude-opus-4-6
Now I have the full picture. Let me make all the changes:
IsPromisorRepo— add--localflagPartialCloneFilterArgsWithDepth— fix doc commentFetchMetadataBranch(git_operations.go) — fix doc commentFetchMetadataTreeOnly— fix doc commentFetchV2MainTreeOnly— fix doc commentFetchV2MainRef— fix doc comment
Assistant· claude-opus-4-6
Now update the doc comments in git_operations.go.
Assistant· claude-opus-4-6
Now run the tests.
Assistant· claude-opus-4-6
All passing. Let me also add a test that verifies
--localscoping — a global config shouldn't trigger promisor detection.Assistant· claude-opus-4-6
Good,
filepathis already imported. Let me run the tests.Assistant· claude-opus-4-6
All passing. Let me also verify the full build compiles and run the broader test suite.
Assistant· claude-opus-4-6
Here's a summary of all changes:
cmd/entire/cli/strategy/common.go:IsPromisorRepo— added--localflag togit configso user/global gitconfig settings don't cause false positives. Also usescontext.WithoutCancel(ctx)(from previous fix) so canceled contexts don't permanently cachefalse.PartialCloneFilterArgsWithDepth— updated doc comment: clarified non-promisor repos get a shallow fetch (with blobs), not a treeless fetch.
cmd/entire/cli/git_operations.go: 3.FetchMetadataBranch— doc comment now describes conditional behavior (treeless for promisor, shallow for non-promisor). 4.FetchMetadataTreeOnly— doc comment no longer claims--filter=blob:noneis always used; describes both paths. 5.FetchV2MainTreeOnly— same treatment. 6.FetchV2MainRef— same treatment.cmd/entire/cli/strategy/common_test.go: 7.IgnoresGlobalConfigtest — verifies that set only at global level doesn't mark a repo as promisor.- User
commit
Assistant· claude-opus-4-6
Committed as
e42c0fe29. Working tree is clean.