git_operations: simplify metadata-fetch options and reuse test helper · Entire
git_operations: simplify metadata-fetch options and reuse test helper
46c209c→main·Soph·1mo ago·2 files·+11 added/-37 removed
Cleanups from /simplify review (no behavior change):
- Collapse fetchMetadataOpts to a single noFilter bool. After dropping the Shallow field, the struct held only NoFilter plus a dead Unshallow field (never set true by any caller); the two named wrappers FetchMetadataBranch / FetchMetadataTreeOnly document intent at the only two call sites.
- Reuse the existing gitOutput test helper instead of the duplicate gitOut, and drop the thin gitRevParse wrapper.
Co-Authored-By: Claude Opus 4.8 (1M context) noreply@anthropic.com
Sessions
9bf304d541d6View transcript
Changes
2
cmd/entire/cli
Mgit_operations.go+7/-13
Mtreeless_fetch_full_depth_test.go+4/-24
409 unmodified lines
// Does NOT --unshallow: --unshallow is a global property of the clone, so on
// shallow checkpoint repos it would also deepen unrelated branches.
func FetchMetadataBranch(ctx context.Context) error {
return fetchMetadataFromOrigin(ctx, fetchMetadataOpts{NoFilter: true})
}
// FetchMetadataTreeOnly fetches the entire/checkpoints/v1 commit+tree graph
// remote-tracking ref connected; git fetches incrementally, so after the first
// fetch only new commits/trees travel.
func FetchMetadataTreeOnly(ctx context.Context) error {
return fetchMetadataFromOrigin(ctx, fetchMetadataOpts{})
}
type fetchMetadataOpts struct {
NoFilter bool
Unshallow bool
}
func fetchMetadataFromOrigin(ctx context.Context, fopts fetchMetadataOpts) error {
refs := checkpoint.ResolveCommittedRefs(ctx)
if !refs.Primary.IsBranch() {
return fmt.Errorf("primary metadata ref %s is not a branch", refs.Primary)
}
refSpec := fmt.Sprintf("+refs/heads/%s:refs/remotes/origin/%s", branchName, branchName)
output, fetchErr := remote.Fetch(ctx, remote.FetchOptions{
Remote: fetchTarget,
RefSpecs: []string{refSpec},
NoTags: true,
NoFilter: fopts.NoFilter,
Unshallow: fopts.Unshallow,
})
if fetchErr != nil {
if ctx.Err() == context.DeadlineExceeded {
// Handle deadline exceeded error
}
}
}
// Code blocks and additional implementations