rename GetMetadataBranchTree to GetMetadataRefTree · Entire

rename GetMetadataBranchTree to GetMetadataRefTree

a566652→main ·

pfleidi·1mo ago·4 files·+13 added/-16 removed

Take the ref name as a parameter rather than hardcoding the v1 branch. Every caller now passes its intended ref at the call site.

This is a pure refactor: all callers still pass the v1 branch ref. A subsequent commit switches the rewind picker to the topology read ref. The rename makes v1-pinning enforced by code at the resume.go fetch chain and explain.go blob prefetch sites, rather than relying on the implicit name.

Sessions

f4cd111aa5a3View transcript

[?
Finish Checkpoints v1.1 Topology CoverageClaude Code·Opus 4.7[1m]·1 step](/content/gh/entireio/cli/session/a38d5b65-e04c-4025-b7ec-8f2b68cd2df5#timeline-f4cd111aa5a3/index.html)

Changes

4

821 unmodified lines

822
823
824
825
825
826
827
828

821 unmodified lines

}

func loadV1MetadataRootTree(repo *git.Repository) (*object.Tree, error) {
    if tree, err := strategy.GetMetadataBranchTree(repo); err == nil {
    if tree, err := strategy.GetMetadataRefTree(repo, plumbing.NewBranchReferenceName(paths.MetadataBranchName)); err == nil {
        return tree, nil
    }
    tree, err := strategy.GetRemoteMetadataBranchTree(repo)

Mcmd/entire/cli/explain.go+1/-1

340 unmodified lines

341
342
343
344
344
345
346
347
17 unmodified lines

365
366
367
368
368
369
370
371
15 unmodified lines

387
388
389
390
390
391
392
393
11 unmodified lines

405
406
407
408
408
409
410
411

340 unmodified lines

freshRepo, freshErr := openRepository(ctx)
    if freshErr == nil {
        logRefHash(freshRepo, "checkpoint-remote")
        metadataTree, treeErr := strategy.GetMetadataBranchTree(freshRepo)
        metadataTree, treeErr := strategy.GetMetadataRefTree(freshRepo, plumbing.NewBranchReferenceName(paths.MetadataBranchName))
        if treeErr == nil {
            logging.Debug(logCtx, "metadata tree obtained via checkpoint remote fetch",
                slog.String("tree_hash", metadataTree.Hash.String()),
        17 unmodified lines

freshRepo, repoErr := openRepository(ctx)
    if repoErr == nil {
        logRefHash(freshRepo, "treeless-fetch")
        metadataTree, treeErr := strategy.GetMetadataBranchTree(freshRepo)
        metadataTree, treeErr := strategy.GetMetadataRefTree(freshRepo, plumbing.NewBranchReferenceName(paths.MetadataBranchName))
        if treeErr == nil {
            logging.Debug(logCtx, "metadata tree obtained via treeless fetch",
                slog.String("tree_hash", metadataTree.Hash.String()),
        15 unmodified lines

localRepo, repoErr := openRepository(ctx)
    if repoErr == nil {
        logRefHash(localRepo, "local")
        metadataTree, err := strategy.GetMetadataBranchTree(localRepo)
        metadataTree, err := strategy.GetMetadataRefTree(localRepo, plumbing.NewBranchReferenceName(paths.MetadataBranchName))
        if err == nil {
            logging.Debug(logCtx, "metadata tree obtained from local branch",
                slog.String("tree_hash", metadataTree.Hash.String()),
        11 unmodified lines

freshRepo, repoErr := openRepository(ctx)
    if repoErr == nil {
        logRefHash(freshRepo, "full-fetch")
        metadataTree, treeErr := strategy.GetMetadataBranchTree(freshRepo)
        metadataTree, treeErr := strategy.GetMetadataRefTree(freshRepo, plumbing.NewBranchReferenceName(paths.MetadataBranchName))
        if treeErr == nil {
            logging.Debug(logCtx, "metadata tree obtained via full fetch",
                slog.String("tree_hash", metadataTree.Hash.String()),
    

Mcmd/entire/cli/resume.go+4/-4

759 unmodified lines

760
761
762
763
764
765
766
763
764
765
766
768
767
768
770
771
769
770
773
771
772
775
773
774
778
775
776
777
778

759 unmodified lines

return &metadata, nil
}

// GetMetadataBranchTree returns the tree object for the entire/checkpoints/v1 branch.
func GetMetadataBranchTree(repo *git.Repository) (*object.Tree, error) {
    refName := plumbing.NewBranchReferenceName(paths.MetadataBranchName)
    ref, err := repo.Reference(refName, true)
// GetMetadataRefTree returns the tree object at the given committed-metadata ref.
func GetMetadataRefTree(repo *git.Repository, ref plumbing.ReferenceName) (*object.Tree, error) {
    resolvedRef, err := repo.Reference(ref, true)
    if err != nil {
        return nil, fmt.Errorf("failed to get metadata branch reference: %w", err)
        return nil, fmt.Errorf("read ref %s: %w", ref, err)
    }

commit, err := repo.CommitObject(ref.Hash())
    commit, err := repo.CommitObject(resolvedRef.Hash())
    if err != nil {
        return nil, fmt.Errorf("failed to get metadata branch commit: %w", err)
        return nil, fmt.Errorf("read commit at %s: %w", ref, err)
    }

tree, err := commit.Tree()
    if err != nil {
        return nil, fmt.Errorf("failed to get metadata branch tree: %w", err)
        return nil, fmt.Errorf("read tree at %s: %w", ref, err)
    }
    return tree, nil
}

Mcmd/entire/cli/strategy/common.go+7/-10

160 unmodified lines

161
162
163
164
164
165
166
167

160 unmodified lines

}

// Get metadata branch tree for reading session prompts (best-effort, ignore errors)
    metadataTree, _ := GetMetadataBranchTree(repo) //nolint:errcheck // Best-effort for session prompts
    metadataTree, _ := GetMetadataRefTree(repo, plumbing.NewBranchReferenceName(paths.MetadataBranchName)) //nolint:errcheck // Best-effort for session prompts

head, err := repo.Head()
    if err != nil {