pub fn restage(
index_path: &Path,
hash: Kind,
updates: &[(Vec<u8>, Vec<u8>)],
) -> Result<Restaged>Expand description
Points index entries at different blobs, and forgets their cached size.
This is what status --fix is: git’s own git add on a path whose staged
content is plain text, done without spawning git. The blob has to exist in
the object database already — the caller writes it — and this puts the index
entry on it, so the next commit stores the ciphertext.
The stat cache is cleared in the same pass, and not as a nicety: with the old size still recorded, git compares it against the working-tree file, concludes the content changed and never runs the clean filter to find out otherwise. See this module’s opening comment.
Stage 0 only. A path in the middle of a merge has no settled content, and rewriting one side of a conflict to point at a blob nobody asked for would be the worst kind of help.
Reports the paths it actually repointed, not how many. A count cannot say which, and the difference is not cosmetic: a path the index spells differently than the directory does — case folding on macOS and Windows, NFD against NFC — is silently not found, and a caller left to subtract counts would name the wrong file as fixed while the real one vanished from the “still in the clear” list.
§Errors
Error::Io when the index cannot be read or replaced. Error::Config
when an object id is not the length this repository’s hash produces —
writing a short id into an entry would corrupt every entry after it.