Skip to main content

Module git

Module git 

Source
Expand description

What git knows about a directory: where its work tree is, and whether anything under it is tracked.

§Why the index, and why by asking git for it

Tier two’s safety property is “contains no tracked file at any depth”, which is exactly the guarantee git clean enforces and the only reason the tier can be on by default. The index is the authority for it, and getting the index wrong means deleting somebody’s source — so this module asks git ls-files rather than parsing .git/index itself. Split indexes, version-4 path compression, sparse directory entries and linked work trees are all shapes a hand-rolled reader gets wrong quietly, and quietly is the one failure mode a cleaner cannot afford. One subprocess per work tree buys the exact answer.

If git cannot be run, or the repository will not answer, tier two goes inert for that work tree and says so. It never falls back to a guess.

Structs§

WorkTree
One git work tree, with the set of paths its index tracks.

Enums§

Checkout
What the .git at a work tree root actually is.
GitError
Why a work tree could not be consulted.

Functions§

checkout_at
Which kind of checkout is rooted at dir, or None if there is not one.
discover
The nearest ancestor of from, from itself included, that is a git work tree root.
head_on_branch
Whether HEAD names a branch rather than sitting detached.
is_clean
Whether the work tree at dir holds work that exists nowhere else.
is_work_tree_root
Whether dir is the root of a git work tree.