Skip to main content

zero_hunk_state

Function zero_hunk_state 

Source
pub fn zero_hunk_state(f: &FileChange) -> Result<Staged<'_>, EngineError>
Expand description

A file with NO hunks: what it contributes to a tree.

Binary content, a submodule bump and a mode-only change all arrive with zero hunks, so there is nothing to apply and the recorded oid is the only content there is. Never returns Staged::Apply.

Deliberately a third rule rather than a flag on final_state, for the same reason cumulative_state is: the rules genuinely differ. final_state answers Apply for a mode-only text change, and applying zero hunks would rewrite a blob whose bytes are already correct — work, and a second oid for content git already has.