Skip to main content

working_tree

Function working_tree 

Source
pub fn working_tree(root: &Path) -> Option<WorkingTreeState>
Expand description

Read git status --porcelain=v2 --branch, which reports the branch, the upstream and the divergence in the same call as the paths.

Returns None when git could not be asked or the directory is not a work tree; the caller reports that, because “there is no working tree” is a different answer from “the working tree is clean” and a plan that confused the two would propose committing nothing in a directory that is not a repository.

use majordomus_cli::commit::plan::working_tree;
// "there is no working tree" and "the working tree is clean" are different answers
let plain = tempfile::tempdir().expect("a temporary directory");
assert!(working_tree(plain.path()).is_none());