Skip to main content

resolve_index_state

Function resolve_index_state 

Source
pub fn resolve_index_state(
    arguments: &[OsString],
    pending: &PendingInjection,
    state: IndexVsHead,
) -> CommitOnlyDecision
Expand description

What: Finish a NeedsIndexState decision. &PendingInjection borrows the pending data. Why: An injected --only on a pathless amend or empty commit reuses HEAD’s tree, so a dirty index would be ignored silently; an equal or unknown index is safe to inject.

In TS you’d write (pseudocode):

if (indexState === 'differs') throw new CommitOnlyViolationError('staged-changes-ignored', ...);
return [...args.slice(0, i + 1), '-o', ...args.slice(i + 1)];