Documentation
¶
Overview ¶
Package land rebases a linear range of commits onto the tip of a ref by applying its tree changes, with a file-level conflict check. It is pure over a read-only object source: it stores nothing and holds no lock.
Index ¶
Constants ¶
const ( // MaxCommits is the longest range that one land takes. MaxCommits = 1000 // MaxLoggedPaths is the most paths that a log row keeps. A land that changes more is logged as overflow. MaxLoggedPaths = 1000 // MaxRewriteBytes is the most new object data that one land may write. MaxRewriteBytes = 32 << 20 // MaxConflictPaths is the most paths that a conflict names. MaxConflictPaths = 1000 )
Variables ¶
var ErrTooLarge = errors.New("land: change is too large")
ErrTooLarge is a land that needs more than the limits allow.
var MaxChangedPaths = 100000
MaxChangedPaths is the most distinct leaves that one land may change.
var MaxObjectBytes = gitpack.MaxObjectBytes
MaxObjectBytes is the largest object that a land may make.
Functions ¶
This section is empty.
Types ¶
type Batch ¶
type Batch struct {
// contains filtered or unexported fields
}
Batch lands changes one after the other on a running tip, and holds the objects that it makes until the caller stores them. A later land of the batch sees the earlier ones. A Batch is for one goroutine.
func NewBatch ¶
NewBatch starts a batch on tip. grow is told how many bytes the batch holds before each read, and may refuse. hist answers the stored lands since a base.
func (*Batch) Land ¶
Land lands base..head on the running tip. A head that descends from the tip moves the ref to head as it is. Any other range is rebuilt on the tip with the commit time when. It returns a *ConflictError when a path of the range also changed since base, and Invalid or ErrTooLarge when the range cannot land. A failed land leaves no trace.
type Change ¶
Change is a leaf that differs between two trees. Old is nil for an addition and New is nil for a removal. A rename is a removal and an addition. A directory that becomes a file is the removal of each leaf under it and the addition of the file.
type Commit ¶
type Commit struct {
Tree gitpack.SHA
Parents []gitpack.SHA
Author string
Committer string
Message []byte
// contains filtered or unexported fields
}
Commit is a parsed commit object.
func ParseCommit ¶
ParseCommit reads the headers and the message of a commit object.
type ConflictError ¶
type ConflictError struct{ Paths []string }
ConflictError is a change that touches a path that also changed since its base.
func (*ConflictError) Error ¶
func (e *ConflictError) Error() string
type Entry ¶
Entry is one entry of a tree. A directory has the mode 040000. Any other entry, a submodule too, is a leaf.
type History ¶
type History func(ctx context.Context, base gitpack.SHA, emit func(path string)) (ok bool, err error)
History emits every path that the stored lands changed from base up to the tip at the start of the batch. It reports ok false, and emits nothing, when the stored lands cannot answer. The caller then diffs trees.
type Invalid ¶
type Invalid string
Invalid is a change that cannot land, whatever the state of the ref. Its text names the reason.
type Landed ¶
type Landed struct {
Old, New gitpack.SHA
FastForward bool
Noop bool
Commits []Mapped
Paths []string
Overflow bool
}
Landed is one land of a batch. Paths holds the changed leaves, and is nil with Overflow set when there are more than MaxLoggedPaths.