storepath

package
v0.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package storepath names where a repository's embargo store lives (adr-2610120558328615). It stands apart from package embargo so a reader that must skip the store, the peers listing, can name it without importing the capture code embargo writes its private records through: capture imports site, site claim, and claim peers, so peers importing embargo is a cycle.

The store is a linked worktree of the repository at worktrees/<key>/embargo in abcd's home, and it is found by that membership: whichever worktree of the repository git lists at a path of that shape is the store, whatever its key. The key is chosen once, when the store is made, from the root commits of the default branch; nothing that changes the roots afterwards moves the store or hides it: a merge of an unrelated history, origin's HEAD moved to another branch, a shallow clone deepened, a replace ref or a graft file. What does hide it is git losing the registration: the store's folder moved or deleted and pruned, or the checkout cloned afresh; a folder left at the place the store would be made is then refused, never taken for "no store".

A worktree of the repository at that shape under some other home (abcd once run under sudo, a sandbox or an aliased HOME) is the store this repository registered, so it is refused (ErrStoreUnderAnotherHome), never read as "no store" and never answered with a second store here.

Which stores the outbound check reads is a wider question (Reachable): every place a store sits under this home, whatever repository it belongs to and whether or not git still lists it, found by listing the worktree store rather than by any root commit, so a second clone whose roots miss the store's key (a shallow clone, rewritten history) still reads it, and a store whose checkout was deleted still has its records read. Those that are not this checkout's own are read, and never written.

Index

Constants

View Source
const Name = "embargo"

Name is the store's folder under its key's level of the worktree store.

Variables

View Source
var ErrNoFreePlace = errors.New("every place the embargo store could be made holds another repository's store")

ErrNoFreePlace is Locate's answer, with no store registered, when the place under every root of the default branch holds another repository's store. This repository has no store; one cannot be made here without touching another's.

View Source
var ErrNoRootCommit = errors.New("the default branch has no root commit to key the embargo store on")

ErrNoRootCommit is Locate's answer, with no store registered, for a repository whose default branch has no root commit to key a store on.

View Source
var ErrPlaceHeldByAClone = fmt.Errorf("%w, each a clone's of the same project", ErrNoFreePlace)

ErrPlaceHeldByAClone is ErrNoFreePlace when each store sitting at those places is a clone's of the same project, under a root of that clone's own default branch: moving it under its own root could not free the place.

View Source
var ErrPlaceTaken = errors.New("something that is not a store of this repository sits where its embargo store would be made")

ErrPlaceTaken is Locate's answer, with no store registered, when something sits at the place the store would be made that is neither this repository's worktree nor shown to be another repository's, or the place cannot be examined: it may be a store whose registration git lost, so it is never answered as "no store".

View Source
var ErrPlaceUnread = errors.New("a place where an embargo store under this home would be cannot be examined")

ErrPlaceUnread is Reachable's answer when the worktree store under the home cannot be listed, or a place worktrees/<key>/embargo in it cannot be examined: it may be a store whose records the check would otherwise miss, so it is never skipped.

View Source
var ErrRootsUnread = errors.New("the root commits of the default branch could not be read")

ErrRootsUnread is Locate's answer, with no store registered, when git could not list the default branch's root commits to key a new store on.

View Source
var ErrSeveralStores = errors.New("more than one embargo store is a worktree of the repository")

ErrSeveralStores is Locate's answer when more than one worktree of the repository is an embargo store: which one holds the records cannot be told, so none is chosen.

View Source
var ErrStoreUnderAnotherHome = errors.New("the embargo store this repository registered lives under another home")

ErrStoreUnderAnotherHome is the answer of Locate and Reachable when git lists a worktree of the repository at the shape of a store under some other home: the store this repository registered lives there, so this home would read as holding nothing, and a store made here would be a second one.

View Source
var ErrWorktreesUnread = errors.New("the repository's worktrees could not be listed")

ErrWorktreesUnread is Locate's answer when git could not list the repository's worktrees, so whether a store is registered cannot be told.

Functions

func HasStoreShape added in v0.15.1

func HasStoreShape(p string) bool

HasStoreShape reports whether p, in its spelling or with its links resolved, ends in .abcd.noindex/worktrees/<key>/embargo under any home: a reader that must never open a store whoever's home it is in, or when no home can be named, skips every path of that shape.

func IsStorePath added in v0.15.1

func IsStorePath(home, p string) bool

IsStorePath reports whether p is the path of an embargo store under home: worktrees/<key>/embargo in abcd's home, the key a full object name (forty or sixty-four lower-case hex digits), in p's spelling or with its links resolved, and the same for home.

func Resolve added in v0.15.1

func Resolve(p string) string

Resolve is filepath.EvalSymlinks over the longest existing prefix of p, with the rest joined on: a path not made yet, or a store's folder deleted while git still lists it, still resolves through the links above it (macOS's /var is one). It is the one spelling every comparison of store and checkout paths makes.

Types

type Location added in v0.15.1

type Location struct {
	// Path is worktrees/<key>/embargo under abcd's home.
	Path string
	// Registered is true when Path is a worktree of the repository, so the
	// store exists as far as git knows; false when Path is where it is to be
	// made, and nothing is there.
	Registered bool
}

Location is where a repository's embargo store is, or is to be made.

func Locate added in v0.15.1

func Locate(home, repoRoot string) (Location, error)

Locate is the one rule for where the store of the repository at repoRoot is under home. Every reader and writer of the store asks here.

Finding: every worktree of the repository (gitutil.EachWorktree) whose path is a store's (IsStorePath) is a store. Exactly one is the store, whatever its key; more than one is ErrSeveralStores; one under another home is ErrStoreUnderAnotherHome; a listing git could not give is ErrWorktreesUnread, never "none".

Making, when none is registered: the place under each root of the default branch (placesUnderRoots), oldest first, so a repository with one root keeps the place it always had. A place holding another repository's live store is passed over and never touched; the first free place is the answer; a place holding anything else, or that cannot be examined, is ErrPlaceTaken; with every place another's, ErrNoFreePlace, or ErrPlaceHeldByAClone when each of those stores sits under a root of its own repository's default branch (keyedOnOwnRoot).

type Reach added in v0.15.1

type Reach struct {
	// Own is the repository's registered store (Locate), "" when none is.
	Own string
	// Others is every other place a store sits under the home, in path
	// order: another clone's of the same project, or another project's,
	// live or not.
	Others []string
	// NotLive is how many of Others are no live worktree (liveWorktree):
	// a store whose repository or checkout is gone, a copy git does not
	// list, or a plain folder.
	NotLive int
}

Reach is every store the outbound check of a repository reads.

func Reachable added in v0.15.1

func Reachable(home, repoRoot string) (Reach, error)

Reachable is the one rule for which stores the outbound check of the repository at repoRoot reads, and it makes and changes nothing.

Own is found as Locate finds the store, with Locate's refusals for the worktree listing, several stores and a store under another home. Others are read from the worktree store under home (storePlaces): every place worktrees/<key>/embargo, the key a full object name, where anything sits, whoever's it is and whether or not it is a live worktree, but Own. Whether a store is live decides nothing of what is read, since what is held comes from its state file alone; NotLive only counts those that are not. A place that cannot be examined, and a worktree store that cannot be listed, are ErrPlaceUnread, never skipped. No root commit is read: the roots decide only where a new store is made.

Its one known limit: a store under another home that this repository never registered (another clone's, made under sudo or a sandbox) is not read.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL