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
type TmpIndex structTmpIndex represents a per-invocation temporary index directory.
#New
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
#NewEmpty
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
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
func GarbageCollectDryRun(safegitDir string) ([]string, error)GarbageCollectDryRun reports orphan tmp directories without removing them. Returns the directory names that would be cleaned.
#TmpIndex.Cleanup
func (t *TmpIndex) Cleanup() errorCleanup removes the temporary index directory.