safegit v0.26.0 /internal/index
On this page

Package index manages per-invocation temporary git indexes so each safegit invocation stages into its own index seeded from HEAD, avoiding contention.

#internal/index

#internal/index

Package index manages per-invocation temporary git indexes so each safegit invocation stages into its own index seeded from HEAD, avoiding contention. No safegit operation writes to the shared .git/index; all staging goes through temporary indexes created here.

#TmpIndex

Go go
type TmpIndex struct

TmpIndex represents a per-invocation temporary index directory.

#New

Go go
func New(ctx context.Context, safegitDir string, treeish string) (*TmpIndex, error)

New creates a temporary index directory and seeds the index from the given treeish. The directory name is - where random is 4 bytes hex.

#NewEmpty

Go go
func NewEmpty(safegitDir string) (*TmpIndex, error)

NewEmpty creates a temporary index directory with an empty index (no tree). Used for root commits in repos with no prior commits.

#GarbageCollect

Go go
func GarbageCollect(safegitDir string) (removed int, err error)

GarbageCollect removes tmp directories whose owning PID is no longer alive. Returns the count of directories removed.

#GarbageCollectDryRun

Go go
func GarbageCollectDryRun(safegitDir string) ([]string, error)

GarbageCollectDryRun reports orphan tmp directories without removing them. Returns the directory names that would be cleaned.

#TmpIndex.Cleanup

Go go
func (t *TmpIndex) Cleanup() error

Cleanup removes the temporary index directory.

Search