Documentation
¶
Overview ¶
Package gittree materializes a git commit's tree to disk, writing every blob as a regular file (or real symlink, where applicable), in parallel. Both the baseline-CAS slot and the git fetcher's worktree slot route through this single implementation; the two callers used to have ~identical sequential variants.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Materialize ¶
func Materialize(ctx context.Context, repo *git.Repository, hash plumbing.Hash, root string, opts Options) error
Materialize walks the tree at hash and writes every blob into root. Symlinks land as real OS symlinks (not collapsed to text files); non-file modes (tree entries, etc.) are silently skipped — the per-blob write MkdirAll's parents on demand. Submodule entries are reported via opts.OnSubmodule and skipped.
Writes run concurrently across opts.Workers goroutines; the walker streams entries through a buffered channel so memory stays bounded even on monorepos with 50k+ blobs. ctx cancellation propagates to every in-flight worker.
Types ¶
type Options ¶
type Options struct {
// Workers caps the number of concurrent blob writes. Zero defaults
// to runtime.NumCPU. Set 1 for deterministic sequential writes
// (the legacy behavior — useful for narrowing down a
// concurrency-sensitive bug).
Workers int
// OnSubmodule, when non-nil, is invoked for each submodule entry
// the walker encounters. flate skips submodules in both source-
// fetcher and baseline contexts (the submodule's state rarely
// matches what flate is rendering); the callback exists so the
// caller can log at the right level / structured shape. Nil
// substitutes a slog.Warn carrying the submodule path.
OnSubmodule func(path string)
}
Options tunes Materialize.