Documentation ¶
Index ¶
- Constants
- Variables
- func Base64Decode(input string, oid plumbing.Hash, b Backend) (any, error)
- func Base64DecodeAs[T Commit | Tree | Fragments | Tag](input string, oid plumbing.Hash, b Backend) (*T, error)
- func Base64Encode(e Encoder) (string, error)
- func Decode(r io.Reader, oid plumbing.Hash, b Backend) (any, error)
- func GetUnifiedText(r io.Reader, size int64, codecvt bool) (string, string, error)
- func Hash(e Encoder) plumbing.Hash
- func HashFrom(r io.Reader) (plumbing.Hash, error)
- func IsErrDirectoryNotFound(err error) bool
- func IsErrEntryNotFound(err error) bool
- func NewFilePatchWrapper(chunks []fdiff.Chunk, from, to fdiff.File, fragments bool) fdiff.FilePatch
- func NewTextChunk(content string, op fdiff.Operation) fdiff.Chunk
- func NewTextFilePatch(chunks []fdiff.Chunk, from, to ChangeEntry, fragments bool) fdiff.FilePatch
- func NewTreeRootNode(t *Tree, m noder.Matcher, conflictDetection bool) noder.Noder
- func NewUnifiedReader(r io.Reader) (io.Reader, error)
- func StatsWriteTo(w io.Writer, fileStats []FileStat, color bool)
- type Backend
- type Blob
- type Change
- type ChangeEntry
- type Changes
- func DetectRenames(ctx context.Context, changes Changes, opts *DiffTreeOptions) (Changes, error)
- func DiffTree(a, b *Tree, m noder.Matcher) (Changes, error)
- func DiffTreeContext(ctx context.Context, a, b *Tree, m noder.Matcher) (Changes, error)
- func DiffTreeWithOptions(ctx context.Context, a, b *Tree, opts *DiffTreeOptions, m noder.Matcher) (Changes, error)
- type Commit
- func (c *Commit) Decode(reader Reader) error
- func (c *Commit) Encode(w io.Writer) error
- func (c *Commit) IsAncestor(ctx context.Context, other *Commit) (bool, error)
- func (c *Commit) Less(rhs *Commit) bool
- func (c *Commit) MakeParents() CommitIter
- func (c *Commit) MergeBase(ctx context.Context, other *Commit) ([]*Commit, error)
- func (c *Commit) NumParents() int
- func (c *Commit) PatchContext(ctx context.Context, to *Commit, m noder.Matcher, codecvt bool) (*Patch, error)
- func (c *Commit) Pretty(w io.Writer) error
- func (c *Commit) Root(ctx context.Context) (*Tree, error)
- func (c *Commit) StatsContext(ctx context.Context, m noder.Matcher, codecvt bool) (FileStats, error)
- func (c *Commit) String() string
- func (c *Commit) Subject() string
- type CommitFilter
- type CommitIter
- func NewCommitAllIter(ctx context.Context, rdb refs.Backend, odb Backend, ...) (CommitIter, error)
- func NewCommitFileIterFromIter(fileName string, commitIter CommitIter, checkParent bool) CommitIter
- func NewCommitIter(b Backend, hashes []plumbing.Hash) CommitIter
- func NewCommitIterBSF(c *Commit, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash) CommitIter
- func NewCommitIterCTime(c *Commit, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash) CommitIter
- func NewCommitLimitIterFromIter(commitIter CommitIter, limitOptions LogLimitOptions) CommitIter
- func NewCommitPathIterFromIter(pathFilter func(string) bool, commitIter CommitIter, checkParent bool) CommitIter
- func NewCommitPostorderIter(c *Commit, ignore []plumbing.Hash) CommitIter
- func NewCommitPreorderIter(c *Commit, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash) CommitIter
- func NewFilterCommitIter(from *Commit, isValid *CommitFilter, isLimit *CommitFilter) CommitIter
- type CompressMethod
- type DiffTreeOptions
- type Encoder
- type ErrDirectoryNotFound
- type ErrEntryNotFound
- type ExtraHeader
- type File
- type FileIter
- type FileStat
- type FileStats
- type Fragment
- type Fragments
- type FragmentsOrder
- type LogLimitOptions
- type ObjectType
- type Patch
- type Printer
- type Reader
- type Signature
- type SubtreeOrder
- type Tag
- type Tree
- func (t *Tree) Append(others *TreeEntry)
- func (t *Tree) Decode(reader Reader) error
- func (t *Tree) Diff(to *Tree, m noder.Matcher) (Changes, error)
- func (t *Tree) DiffContext(ctx context.Context, to *Tree, m noder.Matcher) (Changes, error)
- func (t *Tree) Encode(w io.Writer) error
- func (t *Tree) Entry(name string) (*TreeEntry, error)
- func (t *Tree) Equal(other *Tree) bool
- func (t *Tree) Files() *FileIter
- func (t *Tree) FindEntry(ctx context.Context, relativePath string) (*TreeEntry, error)
- func (t *Tree) Merge(others ...*TreeEntry) *Tree
- func (t *Tree) Patch(to *Tree, m noder.Matcher, codecvt bool) (*Patch, error)
- func (t *Tree) PatchContext(ctx context.Context, to *Tree, m noder.Matcher, codecvt bool) (*Patch, error)
- func (t *Tree) Pretty(w io.Writer) error
- func (t *Tree) SizePadding() int
- func (t *Tree) SpacePadding() int
- func (t *Tree) Tree(ctx context.Context, path string) (*Tree, error)
- type TreeEntry
- func (e *TreeEntry) Chmod(other *TreeEntry) bool
- func (e *TreeEntry) Clone() *TreeEntry
- func (e *TreeEntry) Equal(other *TreeEntry) bool
- func (e *TreeEntry) IsFragments() bool
- func (e *TreeEntry) IsLink() bool
- func (e *TreeEntry) Modified(other *TreeEntry) bool
- func (e *TreeEntry) OriginMode() filemode.FileMode
- func (e *TreeEntry) Renamed(other *TreeEntry) bool
- func (e *TreeEntry) Type() ObjectType
- type TreeNoder
- func (t *TreeNoder) Children(ctx context.Context) ([]noder.Noder, error)
- func (t *TreeNoder) Hash() []byte
- func (t *TreeNoder) HashRaw() plumbing.Hash
- func (t *TreeNoder) IsDir() bool
- func (t *TreeNoder) IsFragments() bool
- func (t *TreeNoder) Mode() filemode.FileMode
- func (t *TreeNoder) Name() string
- func (t *TreeNoder) NumChildren(ctx context.Context) (int, error)
- func (t *TreeNoder) Size() int64
- func (t *TreeNoder) Skip() bool
- func (t *TreeNoder) String() string
- func (t *TreeNoder) TrueMode() filemode.FileMode
- type TreeWalker
Constants ¶
const ( BLOB_CURRENT_VERSION uint16 = 1 BLOB_CACHE_SIZE_LIMIT = 1024 * 1024 STORE CompressMethod = 0 ZSTD CompressMethod = 1 BROTLI CompressMethod = 2 DEFLATE CompressMethod = 3 XZ CompressMethod = 4 BZ2 CompressMethod = 5 )
const ( // MAX_DIFF_SIZE 100MiB MAX_DIFF_SIZE = 100 * 1024 * 1024 BINARY = "binary" UTF8 = "UTF-8" )
const (
BlobInlineMaxBytes = 4096
)
const DateFormat = "Mon Jan 02 15:04:05 2006 -0700"
DateFormat is the format being used in the original git implementation
const (
// ZstandardMagic: https://github.com/facebook/zstd/blob/dev/doc/zstd_compression_format.md#frames
ZstandardMagic = 0xFD2FB528
)
Variables ¶
var ( BLOB_MAGIC = [4]byte{'Z', 'B', 0x00, 0x01} BLANK_BLOB_BYTES = [16]byte{'Z', 'B', 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} )
var ( ErrMismatchedMagic = errors.New("mismatched magic") ErrMismatchedVersion = errors.New("mismatched version") )
var ( TREE_MAGIC = [4]byte{'Z', 'T', 0x00, 0x01} ErrMaxTreeDepth = errors.New("maximum tree depth exceeded") )
New errors defined by this package.
var (
COMMIT_MAGIC = [4]byte{'Z', 'C', 0x00, 0x01}
)
var DefaultDiffTreeOptions = &DiffTreeOptions{ DetectRenames: true, RenameScore: 60, RenameLimit: 0, OnlyExactRenames: false, }
DefaultDiffTreeOptions are the default and recommended options for the diff tree.
var (
ErrCanceled = errors.New("operation canceled")
)
var (
ErrNotTextContent = errors.New("not a text content")
)
var (
ErrUnsupportedObject = errors.New("unsupported object type")
)
var (
FRAGMENTS_MAGIC = [4]byte{'Z', 'F', 0x00, 0x01}
)
var (
TAG_MAGIC = [4]byte{'Z', 'G', 0x00, 0x01}
)
Functions ¶
func Base64DecodeAs ¶
func Base64Encode ¶
func GetUnifiedText ¶
GetUnifiedText: Read all text content.
func IsErrDirectoryNotFound ¶
func IsErrEntryNotFound ¶
func NewFilePatchWrapper ¶
func NewTextFilePatch ¶
func NewTreeRootNode ¶
NewTreeRootNode returns the root node of a Tree
func StatsWriteTo ¶
StatsWriteTo prints the stats of changes in content of files. Original implementation: https://github.com/git/git/blob/1a87c842ece327d03d08096395969aca5e0a6996/diff.c#L2615 Parts of the output: <pad><filename><pad>|<pad><changeNumber><pad><+++/---><newline> example: " main.go | 10 +++++++--- "
Types ¶
type Backend ¶
type Backend interface { Commit(ctx context.Context, oid plumbing.Hash) (*Commit, error) Tree(ctx context.Context, oid plumbing.Hash) (*Tree, error) Fragments(ctx context.Context, oid plumbing.Hash) (*Fragments, error) Tag(ctx context.Context, oid plumbing.Hash) (*Tag, error) Blob(ctx context.Context, oid plumbing.Hash) (*Blob, error) }
type Change ¶
type Change struct { From ChangeEntry To ChangeEntry }
Change values represent a detected change between two git trees. For modifications, From is the original status of the node and To is its final status. For insertions, From is the zero value and for deletions To is the zero value.
func (*Change) Action ¶
func (c *Change) Action() (merkletrie.Action, error)
Action returns the kind of action represented by the change, an insertion, a deletion or a modification.
func (*Change) Files ¶
Files returns the files before and after a change. For insertions from will be nil. For deletions to will be nil.
func (*Change) Patch ¶
Patch returns a Patch with all the file changes in chunks. This representation can be used to create several diff outputs.
func (*Change) PatchContext ¶
Patch returns a Patch with all the file changes in chunks. This representation can be used to create several diff outputs. If context expires, an non-nil error will be returned Provided context must be non-nil
type ChangeEntry ¶
type ChangeEntry struct { // Full path of the node using "/" as separator. Name string // Parent tree of the node that has changed. Tree *Tree // The entry of the node. TreeEntry TreeEntry }
ChangeEntry values represent a node that has suffered a change.
func (*ChangeEntry) Equal ¶
func (e *ChangeEntry) Equal(o *ChangeEntry) bool
func (*ChangeEntry) IsFragments ¶
func (e *ChangeEntry) IsFragments() bool
type Changes ¶
type Changes []*Change
Changes represents a collection of changes between two git trees. Implements sort.Interface lexicographically over the path of the changed files.
func DetectRenames ¶
DetectRenames detects the renames in the given changes on two trees with the given options. It will return the given changes grouping additions and deletions into modifications when possible. If options is nil, the default diff tree options will be used.
func DiffTree ¶
DiffTree compares the content and mode of the blobs found via two tree objects. DiffTree does not perform rename detection, use DiffTreeWithOptions instead to detect renames.
func DiffTreeContext ¶
DiffTreeContext compares the content and mode of the blobs found via two tree objects. Provided context must be non-nil. An error will be returned if context expires.
func DiffTreeWithOptions ¶
func DiffTreeWithOptions( ctx context.Context, a, b *Tree, opts *DiffTreeOptions, m noder.Matcher, ) (Changes, error)
DiffTreeWithOptions compares the content and mode of the blobs found via two tree objects with the given options. The provided context must be non-nil. If no options are passed, no rename detection will be performed. The recommended options are DefaultDiffTreeOptions. An error will be returned if the context expires. This function will be deprecated and removed in v6 so the default behaviour of DiffTree is to detect renames.
func (Changes) Patch ¶
Patch returns a Patch with all the changes in chunks. This representation can be used to create several diff outputs.
func (Changes) PatchContext ¶
Patch returns a Patch with all the changes in chunks. This representation can be used to create several diff outputs. If context expires, an non-nil error will be returned Provided context must be non-nil
type Commit ¶
type Commit struct { Hash plumbing.Hash `json:"hash"` // commit oid // Author is the Author this commit, or the original writer of the // contents. // // NOTE: this field is stored as a string to ensure any extra "cruft" // bytes are preserved through migration. Author Signature `json:"author"` // Committer is the individual or entity that added this commit to the // history. // // NOTE: this field is stored as a string to ensure any extra "cruft" // bytes are preserved through migration. Committer Signature `json:"committer"` // ParentIDs are the IDs of all parents for which this commit is a // linear child. Parents []plumbing.Hash `json:"parents"` // Tree is the root Tree associated with this commit. Tree plumbing.Hash `json:"tree"` // ExtraHeaders stores headers not listed above, for instance // "encoding", "gpgsig", or "mergetag" (among others). ExtraHeaders []*ExtraHeader `json:"-"` // Message is the commit message, including any signing information // associated with this commit. Message string `json:"message"` // contains filtered or unexported fields }
func Independents ¶
Independents returns a subset of the passed commits, that are not reachable the others It mimics the behavior of `git merge-base --independent commit...`.
func NewSnapshotCommit ¶
func (*Commit) IsAncestor ¶
IsAncestor returns true if the actual commit is ancestor of the passed one. It returns an error if the history is not transversable It mimics the behavior of `git merge --is-ancestor actual other`
func (*Commit) Less ¶
Less defines a compare function to determine which commit is 'earlier' by: - First use Committer.When - If Committer.When are equal then use Author.When - If Author.When also equal then compare the string value of the hash
func (*Commit) MakeParents ¶
func (c *Commit) MakeParents() CommitIter
Parents return a CommitIter to the parent Commits.
func (*Commit) MergeBase ¶
MergeBase mimics the behavior of `git merge-base actual other`, returning the best common ancestor between the actual and the passed one. The best common ancestors can not be reached from other common ancestors.
func (*Commit) NumParents ¶
NumParents returns the number of parents in a commit.
func (*Commit) PatchContext ¶
func (c *Commit) PatchContext(ctx context.Context, to *Commit, m noder.Matcher, codecvt bool) (*Patch, error)
PatchContext returns the Patch between the actual commit and the provided one. Error will be return if context expires. Provided context must be non-nil.
NOTE: Since version 5.1.0 the renames are correctly handled, the settings used are the recommended options DefaultDiffTreeOptions.
type CommitFilter ¶
CommitFilter returns a boolean for the passed Commit
type CommitIter ¶
type CommitIter interface { Next(context.Context) (*Commit, error) ForEach(context.Context, func(*Commit) error) error Close() }
CommitIter is a generic closable interface for iterating over commits.
func NewCommitAllIter ¶
func NewCommitAllIter(ctx context.Context, rdb refs.Backend, odb Backend, commitIterFunc func(*Commit) CommitIter) (CommitIter, error)
NewCommitAllIter returns a new commit iterator for all refs. repoStorer is a repo Storer used to get commits and references. commitIterFunc is a commit iterator function, used to iterate through ref commits in chosen order
func NewCommitFileIterFromIter ¶
func NewCommitFileIterFromIter(fileName string, commitIter CommitIter, checkParent bool) CommitIter
NewCommitFileIterFromIter is kept for compatibility, can be replaced with NewCommitPathIterFromIter
func NewCommitIter ¶
func NewCommitIter(b Backend, hashes []plumbing.Hash) CommitIter
func NewCommitIterBSF ¶
func NewCommitIterBSF( c *Commit, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash, ) CommitIter
NewCommitIterBSF returns a CommitIter that walks the commit history, starting at the given commit and visiting its parents in pre-order. The given callback will be called for each visited commit. Each commit will be visited only once. If the callback returns an error, walking will stop and will return the error. Other errors might be returned if the history cannot be traversed (e.g. missing objects). Ignore allows to skip some commits from being iterated.
func NewCommitIterCTime ¶
func NewCommitIterCTime( c *Commit, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash, ) CommitIter
NewCommitIterCTime returns a CommitIter that walks the commit history, starting at the given commit and visiting its parents while preserving Committer Time order. this appears to be the closest order to `git log` The given callback will be called for each visited commit. Each commit will be visited only once. If the callback returns an error, walking will stop and will return the error. Other errors might be returned if the history cannot be traversed (e.g. missing objects). Ignore allows to skip some commits from being iterated.
func NewCommitLimitIterFromIter ¶
func NewCommitLimitIterFromIter(commitIter CommitIter, limitOptions LogLimitOptions) CommitIter
func NewCommitPathIterFromIter ¶
func NewCommitPathIterFromIter(pathFilter func(string) bool, commitIter CommitIter, checkParent bool) CommitIter
NewCommitPathIterFromIter returns a commit iterator which performs diffTree between successive trees returned from the commit iterator from the argument. The purpose of this is to find the commits that explain how the files that match the path came to be. If checkParent is true then the function double checks if potential parent (next commit in a path) is one of the parents in the tree (it's used by `git log --all`). pathFilter is a function that takes path of file as argument and returns true if we want it
func NewCommitPostorderIter ¶
func NewCommitPostorderIter(c *Commit, ignore []plumbing.Hash) CommitIter
NewCommitPostorderIter returns a CommitIter that walks the commit history like WalkCommitHistory but in post-order. This means that after walking a merge commit, the merged commit will be walked before the base it was merged on. This can be useful if you wish to see the history in chronological order. Ignore allows to skip some commits from being iterated.
func NewCommitPreorderIter ¶
func NewCommitPreorderIter( c *Commit, seenExternal map[plumbing.Hash]bool, ignore []plumbing.Hash, ) CommitIter
NewCommitPreorderIter returns a CommitIter that walks the commit history, starting at the given commit and visiting its parents in pre-order. The given callback will be called for each visited commit. Each commit will be visited only once. If the callback returns an error, walking will stop and will return the error. Other errors might be returned if the history cannot be traversed (e.g. missing objects). Ignore allows to skip some commits from being iterated.
func NewFilterCommitIter ¶
func NewFilterCommitIter( from *Commit, isValid *CommitFilter, isLimit *CommitFilter, ) CommitIter
NewFilterCommitIter returns a CommitIter that walks the commit history, starting at the passed commit and visiting its parents in Breadth-first order. The commits returned by the CommitIter will validate the passed CommitFilter. The history won't be transversed beyond a commit if isLimit is true for it. Each commit will be visited only once. If the commit history can not be traversed, or the Close() method is called, the CommitIter won't return more commits. If no isValid is passed, all ancestors of from commit will be valid. If no isLimit is limit, all ancestors of all commits will be visited.
type CompressMethod ¶
type CompressMethod uint16
type DiffTreeOptions ¶
type DiffTreeOptions struct { // DetectRenames is whether the diff tree will use rename detection. DetectRenames bool // RenameScore is the threshold to of similarity between files to consider // that a pair of delete and insert are a rename. The number must be // exactly between 0 and 100. RenameScore uint // RenameLimit is the maximum amount of files that can be compared when // detecting renames. The number of comparisons that have to be performed // is equal to the number of deleted files * the number of added files. // That means, that if 100 files were deleted and 50 files were added, 5000 // file comparisons may be needed. So, if the rename limit is 50, the number // of both deleted and added needs to be equal or less than 50. // A value of 0 means no limit. RenameLimit uint // OnlyExactRenames performs only detection of exact renames and will not perform // any detection of renames based on file similarity. OnlyExactRenames bool }
DiffTreeOptions are the configurable options when performing a diff tree.
type ErrDirectoryNotFound ¶
type ErrDirectoryNotFound struct {
// contains filtered or unexported fields
}
func (*ErrDirectoryNotFound) Error ¶
func (e *ErrDirectoryNotFound) Error() string
type ErrEntryNotFound ¶
type ErrEntryNotFound struct {
// contains filtered or unexported fields
}
func (*ErrEntryNotFound) Error ¶
func (e *ErrEntryNotFound) Error() string
type ExtraHeader ¶
type ExtraHeader struct { // K is the header key, or the first run of bytes up until a ' ' (\x20) // character. K string // V is the header value, or the remaining run of bytes in the line, // stripping off the above "K" field as a prefix. V string }
ExtraHeader encapsulates a key-value pairing of header key to header value. It is stored as a struct{string, string} in memory as opposed to a map[string]string to maintain ordering in a byte-for-byte encode/decode round trip.
type File ¶
type File struct { // Name is the path of the file. It might be relative to a tree, // depending of the function that generates it. Name string // Mode is the file mode. Mode filemode.FileMode // Hash of the blob. Hash plumbing.Hash // Size of the (uncompressed) blob. Size int64 // contains filtered or unexported fields }
func (*File) OriginReader ¶
OriginReader return ReadCloser
type FileIter ¶
type FileIter struct {
// contains filtered or unexported fields
}
FileIter provides an iterator for the files in a tree.
func NewFileIter ¶
NewFileIter takes a Backend and a Tree and returns a *FileIter that iterates over all files contained in the tree, recursively.
type Fragments ¶
type FragmentsOrder ¶
type FragmentsOrder []*Fragment
func (FragmentsOrder) Len ¶
func (s FragmentsOrder) Len() int
Len implements sort.Interface.Len() and return the length of the underlying slice.
func (FragmentsOrder) Less ¶
func (s FragmentsOrder) Less(i, j int) bool
Less implements sort.Interface.Less() and returns whether the element at "i" is compared as "less" than the element at "j". In other words, it returns if the element at "i" should be sorted ahead of that at "j".
It performs this comparison in lexicographic byte-order according to the rules above (see FragmentsOrder).
func (FragmentsOrder) Swap ¶
func (s FragmentsOrder) Swap(i, j int)
Swap implements sort.Interface.Swap() and swaps the two elements at i and j.
type ObjectType ¶
type ObjectType int8
const ( InvalidObject ObjectType = 0 CommitObject ObjectType = 1 TreeObject ObjectType = 2 BlobObject ObjectType = 3 TagObject ObjectType = 4 // 5 reserved for future expansion OFSDeltaObject ObjectType = 6 REFDeltaObject ObjectType = 7 FragmentsObject ObjectType = 8 // File Fragmentation Extension AnyObject ObjectType = -127 )
func HashObject ¶
func ObjectTypeFromString ¶
func ObjectTypeFromString(s string) ObjectType
ObjectTypeFromString converts from a given string to an ObjectType enumeration instance.
func (ObjectType) MarshalJSON ¶
func (t ObjectType) MarshalJSON() ([]byte, error)
func (ObjectType) String ¶
func (t ObjectType) String() string
func (*ObjectType) UnmarshalJSON ¶
func (t *ObjectType) UnmarshalJSON(b []byte) error
type Patch ¶
type Patch struct {
// contains filtered or unexported fields
}
Patch is an implementation of fdiff.Patch interface
func (*Patch) FilePatches ¶
type Signature ¶
type Signature struct { Name string `json:"name"` Email string `json:"email"` When time.Time `json:"when"` }
type SubtreeOrder ¶
type SubtreeOrder []*TreeEntry
SubtreeOrder is an implementation of sort.Interface that sorts a set of `*TreeEntry`'s according to "subtree" order. This ordering is required to write trees in a correct, readable format to the Git object database.
The format is as follows: entries are sorted lexicographically in byte-order, with subtrees (entries of Type() == object.TreeObjectType) being sorted as if their `Name` fields ended in a "/".
See: https://github.com/git/git/blob/v2.13.0/fsck.c#L492-L525 for more details.
func (SubtreeOrder) Len ¶
func (s SubtreeOrder) Len() int
Len implements sort.Interface.Len() and return the length of the underlying slice.
func (SubtreeOrder) Less ¶
func (s SubtreeOrder) Less(i, j int) bool
Less implements sort.Interface.Less() and returns whether the element at "i" is compared as "less" than the element at "j". In other words, it returns if the element at "i" should be sorted ahead of that at "j".
It performs this comparison in lexicographic byte-order according to the rules above (see SubtreeOrder).
func (SubtreeOrder) Name ¶
func (s SubtreeOrder) Name(i int) string
Name returns the name for a given entry indexed at "i", which is a C-style string ('\0' terminated unless it's a subtree), optionally terminated with '/' if it's a subtree.
This is done because '/' sorts ahead of '\0', and is compatible with the tree order in upstream Git.
func (SubtreeOrder) Swap ¶
func (s SubtreeOrder) Swap(i, j int)
Swap implements sort.Interface.Swap() and swaps the two elements at i and j.
type Tag ¶
type Tag struct { Hash plumbing.Hash `json:"hash"` Object plumbing.Hash `json:"object"` ObjectType ObjectType `json:"type"` Name string `json:"name"` Tagger Signature `json:"tagger"` Content string `json:"content"` }
func (*Tag) Decode ¶
Decode implements Object.Decode and decodes the uncompressed tag being read. It returns the number of uncompressed bytes being consumed off of the stream, which should be strictly equal to the size given.
If any error was encountered along the way it will be returned, and the receiving *Tag is considered invalid.
func (*Tag) Encode ¶
Encode encodes the Tag's contents to the given io.Writer, "w". If there was any error copying the Tag's contents, that error will be returned.
Otherwise, the number of bytes written will be returned.
func (*Tag) Equal ¶
Equal returns whether the receiving and given Tags are equal, or in other words, whether they are represented by the same SHA-1 when saved to the object database.
type Tree ¶
type Tree struct { Hash plumbing.Hash `json:"hash"` Entries []*TreeEntry `json:"entries"` // contains filtered or unexported fields }
Tree is basically like a directory - it references a bunch of other trees and/or blobs (i.e. files and sub-directories)
func NewSnapshotTree ¶
func (*Tree) DiffContext ¶
DiffContext returns a list of changes between this tree and the provided one Error will be returned if context expires. Provided context must be non nil.
NOTE: Since version 5.1.0 the renames are correctly handled, the settings used are the recommended options DefaultDiffTreeOptions.
func (*Tree) Equal ¶
Equal returns whether the receiving and given trees are equal, or in other words, whether they are represented by the same BLAKE3 when saved to the object database.
func (*Tree) Merge ¶
Merge performs a merge operation against the given set of `*TreeEntry`'s by either replacing existing tree entries of the same name, or appending new entries in sub-tree order.
It returns a copy of the tree, and performs the merge in O(n*log(n)) time.
func (*Tree) Patch ¶
Patch returns a slice of Patch objects with all the changes between trees in chunks. This representation can be used to create several diff outputs.
func (*Tree) PatchContext ¶
func (t *Tree) PatchContext(ctx context.Context, to *Tree, m noder.Matcher, codecvt bool) (*Patch, error)
PatchContext returns a slice of Patch objects with all the changes between trees in chunks. This representation can be used to create several diff outputs. If context expires, an error will be returned. Provided context must be non-nil.
NOTE: Since version 5.1.0 the renames are correctly handled, the settings used are the recommended options DefaultDiffTreeOptions.
func (*Tree) SizePadding ¶
func (*Tree) SpacePadding ¶
type TreeEntry ¶
type TreeEntry struct { Name string `json:"name"` Size int64 `json:"size"` Mode filemode.FileMode `json:"mode"` Hash plumbing.Hash `json:"hash"` Payload []byte `json:"-"` }
TreeEntry represents a file
func (*TreeEntry) Equal ¶
Equal returns whether the receiving and given TreeEntry instances are identical in name, filemode, and OID.
func (*TreeEntry) IsFragments ¶
func (*TreeEntry) IsLink ¶
IsLink returns true if the given TreeEntry is a blob which represents a symbolic link (i.e., with a filemode of 0120000.
func (*TreeEntry) OriginMode ¶
func (*TreeEntry) Type ¶
func (e *TreeEntry) Type() ObjectType
type TreeNoder ¶
type TreeNoder struct {
// contains filtered or unexported fields
}
A treenoder is a helper type that wraps git trees into merkletrie noders.
As a merkletrie noder doesn't understand the concept of modes (e.g. file permissions), the treenoder includes the mode of the git tree in the hash, so changes in the modes will be detected as modifications to the file contents by the merkletrie difftree algorithm. This is consistent with how the "git diff-tree" command works.
func (*TreeNoder) Children ¶
Children will return the children of a treenoder as treenoders, building them from the children of the wrapped git tree.
func (*TreeNoder) IsFragments ¶
func (*TreeNoder) NumChildren ¶
len(t.tree.Entries) != the number of elements walked by treewalker for some reason because of empty directories, submodules, etc, so we have to walk here.
type TreeWalker ¶
type TreeWalker struct {
// contains filtered or unexported fields
}
TreeWalker provides a means of walking through all of the entries in a Tree.
func NewTreeWalker ¶
NewTreeWalker returns a new TreeWalker for the given tree.
It is the caller's responsibility to call Close() when finished with the tree walker.
func (*TreeWalker) Close ¶
func (w *TreeWalker) Close()
Close releases any resources used by the TreeWalker.
func (*TreeWalker) Next ¶
Next returns the next object from the tree. Objects are returned in order and subtrees are included. After the last object has been returned further calls to Next() will return io.EOF.
In the current implementation any objects which cannot be found in the underlying repository will be skipped automatically. It is possible that this may change in future versions.
func (*TreeWalker) Tree ¶
func (w *TreeWalker) Tree() *Tree
Tree returns the tree that the tree walker most recently operated on.
Source Files ¶
- blob.go
- change.go
- change_adaptor.go
- commit.go
- commit_walker.go
- commit_walker_bfs.go
- commit_walker_bfs_filtered.go
- commit_walker_ctime.go
- commit_walker_limit.go
- commit_walker_path.go
- difftree.go
- file.go
- fragments.go
- merge_base.go
- object.go
- patch.go
- rename.go
- storage.go
- tag.go
- text.go
- tree.go
- treenode.go