MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / worktree_has_remainder

Function worktree_has_remainder

atomic-agent/src/record/mod.rs:919–947  ·  view source on GitHub ↗

Whether the working tree carries changes beyond the Git HEAD (unstaged or untracked content) — the CB-12A follow-up exact-separability oracle. A clean worktree at the boundary means the turn's recorded content equals the commit tree exactly (no remainder), so the verified capture's HEAD→index delta IS the recorded delta. Read-only; any git failure is conservatively a remainder (never claims exactn

(repo_root: &Path)

Source from the content-addressed store, hash-verified

917/// HEAD→index delta IS the recorded delta. Read-only; any git failure is
918/// conservatively a remainder (never claims exactness).
919fn worktree_has_remainder(repo_root: &Path) -> bool {
920 // `--untracked-files=all` overrides a user's `status.showUntrackedFiles`;
921 // `--no-optional-locks` keeps the stat refresh from rewriting the index.
922 let Ok(output) = std::process::Command::new("git")
923 .args([
924 "--no-optional-locks",
925 "status",
926 "--porcelain",
927 "--untracked-files=all",
928 ])
929 .current_dir(repo_root)
930 .output()
931 else {
932 return true;
933 };
934 if !output.status.success() {
935 return true;
936 }
937 // Atomic-owned state (.atomic/, .vault/) is never content remainder.
938 let stdout = String::from_utf8_lossy(&output.stdout).into_owned();
939 let remainder_lines: Vec<&str> = stdout
940 .lines()
941 .filter(|line| {
942 let path = line.get(3..).unwrap_or(line);
943 !(path.starts_with(".atomic/") || path.starts_with(".vault/"))
944 })
945 .collect();
946 !remainder_lines.is_empty()
947}
948
949/// Git's mode for a path that does not exist on one side of a diff.
950const GIT_ABSENT_MODE: &str = "000000";

Callers 2

classify_git_transitionFunction · 0.85

Calls 6

successMethod · 0.80
getMethod · 0.65
outputMethod · 0.45
collectMethod · 0.45
linesMethod · 0.45
is_emptyMethod · 0.45

Tested by

no test coverage detected