pub struct StagedOnly { /* private fields */ }Expand description
Unstaged changes, set aside for the duration of a stage.
Implementations§
Source§impl StagedOnly
Why COPIES and not git stash --keep-index, and not a patch either.
impl StagedOnly
Why COPIES and not git stash --keep-index, and not a patch either.
Saving is the easy half; restoring is the whole problem.
stash pop MERGES into a tree that already holds the staged content, so it
writes conflict markers into the user’s file. Measured on the first attempt.
git diff + git apply is deterministic on Unix and is what pre-commit
does — but it applies PATCH semantics to text, and Git for Windows converts
line endings by default. Measured on the second attempt: every restore test
failed on Windows and passed everywhere else, which is the worst possible
shape for the one routine in this codebase that can lose somebody’s work.
So: byte-exact copies. Read the file, put it back. No patch to apply, no newline policy to agree about, and binary files need no special case. It costs a temporary copy of only the files that have unstaged changes.
Sourcepub fn enter() -> Result<StagedOnly, String>
pub fn enter() -> Result<StagedOnly, String>
The three early exits, and THE ORDER IS THE DESIGN.
Both of the first two used to return “nothing held” with NO OUTPUT,
which meant the checks silently judged the working tree — the exact
failure this module exists to prevent, announced as a clean run.
docs/index-fidelity-and-run-modes.md §1 says conflicted paths ABORT
the stage; they did not.
- Conflicts first, and they are an
Err: a conflicted path has no staged and unstaged halves to separate, so there is nothing this can honestly do.pre_committurns theErrinto a printed message andVerdict::Block. Safe by construction: git itself refuses a commit with unmerged entries, so nothing that would have succeeded now fails. - Nothing unstaged ⇒ nothing held, SILENTLY. The common case must stay free, and it is not a degraded run: there is no unstaged content for a check to be confused by.
- Mid-operation LAST, and only when there IS unstaged content, with
one printed line. Checked after the conflict test rather than before
it, deliberately: the other order made the ordinary conflicted-merge
case take the mid-operation branch and warn instead of aborting.
Checked after the emptiness test because with a clean tree fidelity
is not actually off, and
registry.rs:64-67calls out on purpose that a resolution commit still runs its checks.