Documentation
¶
Overview ¶
Package stack holds the stack model and its on-disk store.
Index ¶
- Constants
- func ReadStateFile(path string) ([]byte, error)
- func WriteAtomic(path string, data []byte) error
- type Branch
- type CR
- type File
- type Stack
- type Store
- func (st Store) ClearJournal(name string) error
- func (st Store) HasJournal(name string) bool
- func (st Store) Load() (*File, error)
- func (st Store) LoadJournal(name string, v any) (bool, error)
- func (st Store) Lock() (unlock func(), err error)
- func (st Store) Save(f *File) error
- func (st Store) SaveJournal(name string, v any) error
Constants ¶
const ( RebaseJournal = "git-stack-rebase-state" ModifyJournal = "git-stack-modify-state" )
Journal names for paused multi-step operations.
const FormatVersion = 1
FormatVersion is the current metadata file format.
Variables ¶
This section is empty.
Functions ¶
func ReadStateFile ¶
ReadStateFile reads a complete state file, allowing WriteAtomic to replace it while the read is in progress. On Windows, its handle permits delete sharing.
func WriteAtomic ¶
WriteAtomic publishes data at path using a fully written temporary file in the same directory. It preserves an existing regular file's permissions and uses 0644 for a new file. The parent directory must already exist. It does not acquire locks; callers must serialize mutations.
Types ¶
type Branch ¶
type Branch struct {
Name string `json:"name"`
// Base is the parent's tip SHA at the last restack. Commits after Base are this layer's own.
Base string `json:"base,omitempty"`
CR *CR `json:"cr,omitempty"`
Merged bool `json:"merged,omitempty"`
}
Branch is one layer of a stack.
type File ¶
File is the whole metadata file: every stack in the clone.
type Stack ¶
type Stack struct {
Trunk string `json:"trunk"`
Remote string `json:"remote"`
Branches []*Branch `json:"branches"`
}
Stack is an ordered list of branches on top of a trunk; Branches[0] is the bottom.
type Store ¶
type Store struct {
Dir string // git common dir
}
Store reads and writes the metadata file in the git common dir.
func (Store) ClearJournal ¶
ClearJournal removes the named journal.
func (Store) HasJournal ¶
HasJournal reports whether the named journal exists.
func (Store) LoadJournal ¶
LoadJournal reads the named journal into v. It reports false if there is none.
func (Store) Lock ¶
Lock serializes mutations across all worktrees of the clone with an OS file lock (flock, or LockFileEx on Windows), so a lock held by a process that died is released by the OS. It does not wait for a busy lock.
The lock file is left on disk on unlock: removing it would let two processes lock different inodes of the same path (see gh-stack's FileLock).