Skip to main content

worktree_dirty_reason

Function worktree_dirty_reason 

Source
pub fn worktree_dirty_reason(path: &Path) -> Option<String>
Expand description

Why a worktree is not safe to remove, or None when it is clean.

“Dirty” means either uncommitted/untracked changes (git status --porcelain non-empty) OR commits reachable from HEAD and from no remote-tracking ref (git rev-list --count HEAD --not --remotes > 0) - reachability, not the branch’s upstream, which a squash merge leaves permanently ahead. A branch whose configured upstream ref has been deleted was pushed and its remote branch is gone, which is how a squash land reads once the branch is pruned. A repo with no remote-tracking refs stays not-unpushed. The despawn path calls this BEFORE any teardown so a dirty worker is blocked without being killed.