pub enum Restaged {
Nothing,
Staged,
Failed(Vec<String>),
}Expand description
What a re-stage actually did. THREE answers, because the old bool
conflated two of them and the conflation shipped unformatted code.
prettier.rs read if run_quiet(write) && restage(&files) { … Fixed }. When
git add FAILED, restage returned false — indistinguishable from
“nothing needed staging” — so control fell through to a second --check
pass, which inspected the NOW-FORMATTED WORKING TREE, passed, printed
“Prettier passed” and returned Outcome::Passed. The index still held the
unformatted content, so the commit contained unformatted code and the hook
said it had passed. manifest.rs had the same shape.
Variants§
Nothing
No path differed from the index — nothing to do, and nothing wrong.
Staged
git add succeeded; the index now holds the repair.
Failed(Vec<String>)
git add failed, carrying the paths it could not stage. The index
holds content the fixer has already replaced on disk, so this MUST be
loud at every call site — and naming the files is the difference
between a message somebody can act on and one they cannot.