pub fn head_on_branch(dir: &Path) -> boolExpand description
Whether HEAD names a branch rather than sitting detached.
The one way removing a linked work tree can lose a commit. A commit made on a detached
HEAD is reachable only through that work tree’s own HEAD, so once the directory is gone
and the administrative files are pruned nothing refers to it and gc will collect it —
measured, not reasoned about: git fsck --unreachable lists it immediately after. A commit on
a branch is reachable through an ordinary ref in the repository and survives.
Errs toward “detached” on every failure, which is the answer that keeps the directory.