Skip to main content

Crate git_cow

Crate git_cow 

Source
Expand description

Git worktrees cloned from a per-repository template checkout, sharing disk blocks until written. macOS clones whole directories with clonefile(2), Linux uses cp --reflink=always (FICLONE)

Structs§

Occupied
The error inside the io::ErrorKind::AlreadyExists that add_with returns for a wt that exists and is not empty. Test for it with is_occupied
Options
What to share and how often to refresh the template from the checkout
Unsupported
The error inside the io::Error when git-cow cannot clone here at all: the volume has no clone support or the repository has submodules. Test for it with is_unsupported

Enums§

Added
How add_or_plain made the worktree
Foreign
A template path that is not a git-cow extra checkout, inside the io::Error that add_with, warm_with and remove_template return. They leave it alone, and only Options::force in add_with replaces Foreign::Files. The message names the path, the advice is the caller’s

Constants§

DEFAULT_SHARE
Hidden directories that hold only build caches, so they are shared like any other ignored directory. Every other path with a hidden component is tool or agent config and stays out
REPO_ENV
Variables that point git at another repository or index than -C names, set by hooks or git --git-dir. git-cow’s own calls would read or rewrite the user’s repository through them

Functions§

add
Create wt by cloning template, refreshed to template_start and warmed from repo first. new_branch and commitish are git worktree add’s. Like it, refuses a wt that exists and is not empty, and on error removes only the worktree and branch this call created
add_or_plain
add_with, or git worktree add with the same wt, new_branch and commitish when cloning fails. A path is_refused is returned with no plain add
add_with
add with your own Options
can_clone
Whether a file in src_dir clones into dst_dir: both on one volume that supports it. Probed with one small file, since filesystem names miss mount options like XFS without reflink
git
Runs git in dir, without REPO_ENV, and returns its trimmed stdout
is_occupied
Whether e is add_with refusing a wt that exists and is not empty, where a plain git worktree add would fail too
is_refused
Whether e is Occupied or Foreign, a path git-cow leaves alone. A plain git worktree add must not run instead, since the path needs the user first
is_unsupported
Whether e is Unsupported, where a plain git worktree add is expected. Any other clone error also falls back in add_or_plain, and a caller may warn that cloning failed
remove_template
Remove template, its registration in repo, and the lock, stamp and staging files next to it. A path that is not an extra checkout git-cow made fails with Foreign and stays. Call it only when no add or warm on this template can run: one waiting for the lock would get a deleted file, and the next caller a new one
warm
Refresh an existing template with the gitignored directories of src, a checkout or a worktree whose work merged. Shares the hidden directories in DEFAULT_SHARE
warm_with
warm with your own Options. It always warms, the interval only applies to add_with