Expand description
Installing a direct fix’s corrections into the worktree,
all or none.
What:
Install the corrections a converged git cli-git fix settled on into the
worktree,
all of them or none,
and never touch the index.
Why:
The installed wrapper’s direct-fix-install.ts decides this protocol:
every
corrected file must still hold the bytes the fix read,
each replacement is written
beside its file and renamed over it,
a copy of the old file is kept until the end,
and the real index must hold the same bytes afterwards.
Any failure restores every
file already replaced.
Failure messages name no file,
because a pathname can hold
the text a scan exists to keep out of output.
In TS you’d write (pseudocode):
// await installDirectFix({ scope, changedPaths, finalCandidates, originals });Structs§
- Install
Change - What:
One file to correct:
its pathname,
mode,
the bytes the fix read and the bytes to
write.
#[derive(...)]generates cloning, debug printing and==. Why: The read bytes prove nobody changed the file while the fix ran. - Replacement
- What: One prepared replacement: the file, the new bytes beside it, and a copy of the old file beside it. Why: Renaming the new file over the old one replaces it in one step, and the copy restores it if a later step fails.
Constants§
- INSTALL_
SIBLING_ PREFIX - The name prefix of the files a fix writes beside each corrected file.
Functions§
- install_
corrections - What:
Install every change,
or none:
read the real index,
prepare,
then rename and
verify.
Result<(), String>is success or the failure message to report. Why: The whole protocol of the installed wrapper’sinstallDirectFix, apart from the landing lock, which the native wrapper does not take. - install_
prepared - What:
Rename every prepared file over its destination,
then prove the real index still
holds
index_before.&Option<Vec<u8>>borrows the bytes read before, or absence. Why: The fix changes the worktree only. A rename that fails, an index that changed, or an index that cannot be read restores every file already replaced. - prepare_
replacements - What: Prepare every replacement: check the file still holds the bytes the fix read, copy it beside itself, and write the corrected bytes beside it. Why: Nothing in the worktree changes until every file is prepared, so a file that changed under the fix stops it before any file is replaced.
- read_
index - What:
The real index’s bytes,
or nothing when it does not exist.
std::io::Result<Option<Vec<u8>>>is “bytes, absent, or a read failure”. Why: A repository without an index file has an empty index, and must still have none after the fix.