On this page
Package commit implements the two-phase commit pipeline: a parallel-safe staging phase and a serialized ref-update phase with CAS retries.
#internal/commit
#internal/commit
Amend and Reword implement tip-commit rewriting with CAS safety.
#ExitCASExhausted
const ExitCASExhausted = 7Exit codes for commit-specific errors.
#ExitWriteTree
const ExitWriteTree = 9#ExitCommitTree
const ExitCommitTree = 10#AmendRequest
type AmendRequest structAmendRequest holds inputs for an amend operation.
#AmendResult
type AmendResult structAmendResult is the JSON-serializable output of a successful amend.
#RewordRequest
type RewordRequest structRewordRequest holds inputs for a reword operation.
#RewordResult
type RewordResult structRewordResult is the JSON-serializable output of a successful reword.
#CommitError
type CommitError structCommitError carries a structured exit code alongside the error message.
#Pipeline
type Pipeline structPipeline orchestrates the full commit flow.
#FileSpec
type FileSpec structFileSpec describes a file with optional hunk selection for staging.
#CommitRequest
type CommitRequest structCommitRequest holds all inputs for a single commit operation.
#CommitResult
type CommitResult structCommitResult is the JSON-serializable output of a successful commit.
#Pipeline.Amend
func (p *Pipeline) Amend(ctx context.Context, req AmendRequest) (*AmendResult, error)Amend rewrites the tip of the current branch with new files staged. Uses tmp index seeded from HEAD, stages files, builds a new commit with parent = HEAD^ and lock-and-CAS updates the ref.
#Pipeline.Reword
func (p *Pipeline) Reword(ctx context.Context, req RewordRequest) (*RewordResult, error)Reword rewrites only the commit message of the tip of the current branch. Tree and parent remain unchanged. Retries on CAS miss.
#CommitError.Error
func (e *CommitError) Error() string { return e.Message }Error returns the error message.
#Pipeline.Execute
func (p *Pipeline) Execute(ctx context.Context, req CommitRequest) (*CommitResult, error)Execute runs the full two-phase commit pipeline. On CAS miss it retries from Phase A up to Config.Commit.CASMaxAttempts times.