Skip to main content

Module rule_commit_index

Module rule_commit_index 

Source
Expand description

Pure core of the index-against-HEAD check. What: The pure core of the index-against-HEAD check used by the commit-only transform. Why: The caller runs real Git; this module only says which command to run and what its exit status means, so the decision is testable without a process.

In TS you’d write (pseudocode):

// indexStateFromExit(exitCode): 'differs' | 'matches' | 'unknown'

Enums§

IndexVsHead
What: Comparison of staged content with HEAD. An enum is a closed set of alternatives. Why: Unknown means Git could not answer (unborn HEAD, no repository); the transform then defers to real Git instead of rejecting.

Constants§

INDEX_QUERY
The query whose exit status answers the question: 0 for equal, 1 for staged changes.

Functions§

index_query_arguments
What: Build the real-Git argument list: the caller’s global options, then the query. &[OsString] borrows the global prefix; Vec<OsString> is the owned result. Why: The check must inspect the same repository the commit will run in, so -C, --git-dir and the other global options are forwarded unchanged.
index_state_from_exit
What: Interpret the query’s exit status. Option<i32> is “an exit code, or nothing when a signal ended the process”; i32 is the platform’s exit-code integer type. Why: Only the two documented codes are answers; everything else is “Git cannot say”.