safegit v0.26.0 /internal/commit
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

Go go
const ExitCASExhausted  = 7

Exit codes for commit-specific errors.

#ExitWriteTree

Go go
const ExitWriteTree     = 9

#ExitCommitTree

Go go
const ExitCommitTree    = 10

#AmendRequest

Go go
type AmendRequest struct

AmendRequest holds inputs for an amend operation.

#AmendResult

Go go
type AmendResult struct

AmendResult is the JSON-serializable output of a successful amend.

#RewordRequest

Go go
type RewordRequest struct

RewordRequest holds inputs for a reword operation.

#RewordResult

Go go
type RewordResult struct

RewordResult is the JSON-serializable output of a successful reword.

#CommitError

Go go
type CommitError struct

CommitError carries a structured exit code alongside the error message.

#Pipeline

Go go
type Pipeline struct

Pipeline orchestrates the full commit flow.

#FileSpec

Go go
type FileSpec struct

FileSpec describes a file with optional hunk selection for staging.

#CommitRequest

Go go
type CommitRequest struct

CommitRequest holds all inputs for a single commit operation.

#CommitResult

Go go
type CommitResult struct

CommitResult is the JSON-serializable output of a successful commit.

#Pipeline.Amend

Go go
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

Go go
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

Go go
func (e *CommitError) Error() string { return e.Message }

Error returns the error message.

#Pipeline.Execute

Go go
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.

Search