{"modulePath":"github.com/2lambda123/git-lfs","version":"v2.4.2+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package pack\n\n## Variables\n\n```go\nvar (\n\t// ErrShortFanout is an error representing situations where the entire\n\t// fanout table could not be read, and is thus too short.\n\tErrShortFanout = errors.New(\"git/odb/pack: too short fanout table\")\n)\n```\n\n## Functions\n\n```go\nfunc IsNotFound(err error) bool\n```\nIsNotFound returns whether a given error represents a missing object in the index.\n\n## Types\n\n```go\ntype Chain interface {\n\t// Unpack unpacks the data encoded in the delta-base chain up to and\n\t// including the receiving Chain implementation by applying the\n\t// delta-base chain successively to itself.\n\t//\n\t// If there was an error in the delta-base resolution, i.e., the chain\n\t// is malformed, has a bad instruction, or there was a file read error, this\n\t// function is expected to return that error.\n\t//\n\t// In the event that a non-nil error is returned, it is assumed that the\n\t// unpacked data this function returns is malformed, or otherwise\n\t// corrupt.\n\tUnpack() ([]byte, error)\n\n\t// Type returns the type of the receiving chain element.\n\tType() PackedObjectType\n}\n```\nChain represents an element in the delta-base chain corresponding to a packed object.\n\n```go\ntype ChainBase struct {\n\t// contains filtered or unexported fields\n}\n```\nChainBase represents the \"base\" component of a delta-base chain.\n\n```go\nfunc (b *ChainBase) Type() PackedObjectType\n```\nChainBase returns the type of the object it encodes.\n\n```go\nfunc (b *ChainBase) Unpack() ([]byte, error)\n```\nUnpack inflates and returns the uncompressed data encoded in the base element.\n\nIf there was any error in reading the compressed data (invalid headers, etc.), it will be returned immediately.\n\n```go\ntype ChainDelta struct {\n\t// contains filtered or unexported fields\n}\n```\nChainDelta represents a \"delta\" component of a delta-base chain.\n\n```go\nfunc (d *ChainDelta) Type() PackedObjectType\n```\nType returns the type of the base of the delta-base chain.\n\n```go\nfunc (d *ChainDelta) Unpack() ([]byte, error)\n```\nUnpack applies the delta operation to the previous delta-base chain, \"base\".\n\nIf any of the delta-base instructions were invalid, an error will be returned.\n\n```go\ntype Index struct {\n\t// contains filtered or unexported fields\n}\n```\nIndex stores information about the location of objects in a corresponding packfile.\n\n```go\nfunc DecodeIndex(r io.ReaderAt) (*Index, error)\n```\nDecodeIndex decodes an index whose underlying data is supplied by \"r\".\n\nDecodeIndex reads only the header and fanout table, and does not eagerly parse index entries.\n\nIf there was an error parsing, it will be returned immediately.\n\n```go\nfunc (i *Index) Close() error\n```\nClose closes the packfile index if the underlying data stream is closeable. If so, it returns any error involved in closing.\n\n```go\nfunc (i *Index) Count() int\n```\nCount returns the number of objects in the packfile.\n\n```go\nfunc (i *Index) Entry(name []byte) (*IndexEntry, error)\n```\nEntry returns an entry containing the offset of a given SHA1 \"name\".\n\nEntry operates in O(log(n))-time in the worst case, where \"n\" is the number of objects that begin with the first byte of \"name\".\n\nIf the entry cannot be found, (nil, ErrNotFound) will be returned. If there was an error searching for or parsing an entry, it will be returned as (nil, err).\n\nOtherwise, (entry, nil) will be returned.\n\n```go\ntype IndexEntry struct {\n\t// PackOffset is the number of bytes before the associated object in a\n\t// packfile.\n\tPackOffset uint64\n}\n```\nIndexEntry specifies data encoded into an entry in the pack index.\n\n```go\ntype IndexVersion interface {\n\t// Name returns the name of the object located at the given offset \"at\",\n\t// in the Index file \"idx\".\n\t//\n\t// It returns an error if the object at that location could not be\n\t// parsed.\n\tName(idx *Index, at int64) ([]byte, error)\n\n\t// Entry parses and returns the full *IndexEntry located at the offset\n\t// \"at\" in the Index file \"idx\".\n\t//\n\t// If there was an error parsing the IndexEntry at that location, it\n\t// will be returned.\n\tEntry(idx *Index, at int64) (*IndexEntry, error)\n\n\t// Width returns the number of bytes occupied by the header of a\n\t// particular index version.\n\tWidth() int64\n}\n```\nIndexVersion is a constant type that represents the version of encoding used by a particular index version.\n\n```go\ntype Object struct {\n\t// contains filtered or unexported fields\n}\n```\nObject is an encapsulation of an object found in a packfile, or a packed object.\n\n```go\nfunc (o *Object) Type() PackedObjectType\n```\nType returns the underlying object's type. Rather than the type of the front-most delta-base component, it is the type of the object itself.\n\n```go\nfunc (o *Object) Unpack() ([]byte, error)\n```\nUnpack resolves the delta-base chain and returns an uncompressed, unpacked, and full representation of the data encoded by this object.\n\nIf there was any error in unpacking this object, it is returned immediately, and the object's data can be assumed to be corrupt.\n\n```go\ntype OffsetReaderAt struct {\n\t// contains filtered or unexported fields\n}\n```\nOffsetReaderAt transforms an io.ReaderAt into an io.Reader by beginning and advancing all reads at the given offset.\n\n```go\nfunc (r *OffsetReaderAt) Read(p []byte) (n int, err error)\n```\nRead implements io.Reader.Read by reading into the given \\[]byte, \"p\" from the last known offset provided to the OffsetReaderAt.\n\nIt returns any error encountered from the underlying data stream, and advances the reader forward by \"n\", the number of bytes read from the underlying data stream.\n\n```go\ntype PackedObjectType uint8\n```\nPackedObjectType is a constant type that is defined for all valid object types that a packed object can represent.\n\n```go\nconst (\n\t// TypeNone is the zero-value for PackedObjectType, and represents the\n\t// absence of a type.\n\tTypeNone PackedObjectType = iota\n\t// TypeCommit is the PackedObjectType for commit objects.\n\tTypeCommit\n\t// TypeTree is the PackedObjectType for tree objects.\n\tTypeTree\n\t// Typeblob is the PackedObjectType for blob objects.\n\tTypeBlob\n\t// TypeTag is the PackedObjectType for tag objects.\n\tTypeTag\n\n\t// TypeObjectOffsetDelta is the type for OBJ_OFS_DELTA-typed objects.\n\tTypeObjectOffsetDelta PackedObjectType = 6\n\t// TypeObjectReferenceDelta is the type for OBJ_REF_DELTA-typed objects.\n\tTypeObjectReferenceDelta PackedObjectType = 7\n)\n```\n\n```go\nfunc (t PackedObjectType) String() string\n```\nString implements fmt.Stringer and returns an encoding of the type valid for use in the loose object format protocol (see: package 'git/odb' for more).\n\nIf the receiving instance is not defined, String() will panic().\n\n```go\ntype Packfile struct {\n\t// Version is the version of the packfile.\n\tVersion uint32\n\t// Objects is the total number of objects in the packfile.\n\tObjects uint32\n\t// contains filtered or unexported fields\n}\n```\nPackfile encapsulates the behavior of accessing an unpacked representation of all of the objects encoded in a single packfile.\n\n```go\nfunc DecodePackfile(r io.ReaderAt) (*Packfile, error)\n```\nDecodePackfile opens the packfile given by the io.ReaderAt \"r\" for reading. It does not apply any delta-base chains, nor does it do reading otherwise beyond the header.\n\nIf the header is malformed, or otherwise cannot be read, an error will be returned without a corresponding packfile.\n\n```go\nfunc (p *Packfile) Close() error\n```\nClose closes the packfile if the underlying data stream is closeable. If so, it returns any error involved in closing.\n\n```go\nfunc (p *Packfile) Object(name []byte) (*Object, error)\n```\nObject returns a reference to an object packed in the receiving \\*Packfile. It does not attempt to unpack the packfile, rather, that is accomplished by calling Unpack() on the returned \\*Object.\n\nIf there was an error loading or buffering the base, it will be returned without an object.\n\nIf the object given by the SHA-1 name, \"name\", could not be found, (nil, errNotFound) will be returned.\n\nIf the object was able to be loaded successfully, it will be returned without any error.\n\n```go\ntype Set struct {\n\t// contains filtered or unexported fields\n}\n```\nSet allows access of objects stored across a set of packfiles.\n\n```go\nfunc NewSet(db string) (*Set, error)\n```\nNewSet creates a new \\*Set of all packfiles found in a given object database's root (i.e., \"/path/to/repo/.git/objects\").\n\nIt finds all packfiles in the \"pack\" subdirectory, and instantiates a \\*Set containing them. If there was an error parsing the packfiles in that directory, or the directory was otherwise unable to be observed, NewSet returns that error.\n\n```go\nfunc NewSetPacks(packs ...*Packfile) *Set\n```\nNewSetPacks creates a new \\*Set from the given packfiles.\n\n```go\nfunc (s *Set) Close() error\n```\nClose closes all open packfiles, returning an error if one was encountered.\n\n```go\nfunc (s *Set) Object(name []byte) (*Object, error)\n```\nObject opens (but does not unpack, or, apply the delta-base chain) a given object in the first packfile that matches it.\n\nObject searches packfiles contained in the set in order of how many objects they have that begin with the first by of the given SHA-1 \"name\", in descending order.\n\nIf the object was unable to be found in any of the packfiles, (nil, ErrNotFound) will be returned.\n\nIf there was otherwise an error opening the object for reading from any of the packfiles, it will be returned, and no other packfiles will be searched.\n\nOtherwise, the object will be returned without error.\n\n```go\ntype UnsupportedVersionErr struct {\n\t// Got is the unsupported version that was detected.\n\tGot uint32\n}\n```\nUnsupportedVersionErr is a type implementing 'error' which indicates a the presence of an unsupported packfile version.\n\n```go\nfunc (u *UnsupportedVersionErr) Error() string\n```\nError implements 'error.Error()'.\n\n```go\ntype V1 struct{}\n```\nV1 implements IndexVersion for v1 packfiles.\n\n```go\nfunc (v *V1) Entry(idx *Index, at int64) (*IndexEntry, error)\n```\nEntry implements IndexVersion.Entry for v1 packfiles by parsing and returning the IndexEntry specified at the offset \"at\" in the given index file.\n\n```go\nfunc (v *V1) Name(idx *Index, at int64) ([]byte, error)\n```\nName implements IndexVersion.Name by returning the 20 byte SHA-1 object name for the given entry at offset \"at\" in the v1 index file \"idx\".\n\n```go\nfunc (v *V1) Width() int64\n```\nWidth implements IndexVersion.Width() by returning the number of bytes that v1 packfile index header occupy.\n\n```go\ntype V2 struct{}\n```\nV2 implements IndexVersion for v2 packfiles.\n\n```go\nfunc (v *V2) Entry(idx *Index, at int64) (*IndexEntry, error)\n```\nEntry implements IndexVersion.Entry for v2 packfiles by parsing and returning the IndexEntry specified at the offset \"at\" in the given index file.\n\n```go\nfunc (v *V2) Name(idx *Index, at int64) ([]byte, error)\n```\nName implements IndexVersion.Name by returning the 20 byte SHA-1 object name for the given entry at offset \"at\" in the v2 index file \"idx\".\n\n```go\nfunc (v *V2) Width() int64\n```\nWidth implements IndexVersion.Width() by returning the number of bytes that v2 packfile index header occupy.\n\n","path":"github.com/2lambda123/git-lfs/git/odb/pack","name":"pack","synopsis":"","isRedistributable":true}
