Documentation
¶
Overview ¶
Package gitpack reads git pack files and v2 pack indexes by ranged reads.
Index ¶
- Constants
- Variables
- func BuildIdx(entries []IdxEntry, packSum [20]byte) []byte
- func BuildSize(objs []Object) int
- func IdxCount(head []byte) (int, error)
- type IdxEntry
- type IdxIter
- type Object
- type Pack
- func (p *Pack) Bind(r ReaderAt) *Pack
- func (p *Pack) Bytes() int
- func (p *Pack) CachedBytes() int
- func (p *Pack) Count() int
- func (p *Pack) Get(s SHA) (Type, []byte, error)
- func (p *Pack) GetDepth(s SHA) (Type, []byte, int, error)
- func (p *Pack) Has(s SHA) bool
- func (p *Pack) Lookup(s SHA) (int64, bool)
- func (p *Pack) OnCacheChange(f func())
- func (p *Pack) Size(s SHA) (int64, Type, error)
- func (p *Pack) Verify(ctx context.Context, idx, pack []byte) error
- func (p *Pack) WithLookup(f func(SHA) (int64, bool)) *Pack
- type ReaderAt
- type SHA
- type Type
Constants ¶
const ( MaxObjectBytes = 16 << 20 // VerifyWorkBytes bounds the working memory of Verify: the base cache, the object kept past it, and the delta, its // base and its result while one object resolves. VerifyWorkBytes = verifyCacheBytes + 4*MaxObjectBytes )
const IdxHeadBytes = idxHead
IdxHeadBytes is the size of the header and the fanout table of a v2 index.
const MaxUnpackBytes = 64 << 20
MaxUnpackBytes bounds the inflated bytes that Unpack reads from entries and the bytes of the objects that it returns, each.
const MaxUnpackObjects = 100000
MaxUnpackObjects bounds the objects of one pack that Unpack reads.
Variables ¶
var ( ErrCorrupt = errors.New("gitpack: corrupt pack or index") ErrTooLarge = errors.New("gitpack: object too large") )
var ErrNotFound = errors.New("object not found")
Functions ¶
func BuildIdx ¶ added in v0.10.0
BuildIdx writes the v2 index of a pack from entries sorted by name. packSum is the trailer of the pack.
Types ¶
type IdxEntry ¶ added in v0.10.0
IdxEntry is one object of a pack index: its name, the CRC-32 of its entry and its offset.
type IdxIter ¶ added in v0.10.0
type IdxIter struct {
// contains filtered or unexported fields
}
IdxIter reads the names and offsets of a v2 index in name order with ranged reads, so a caller can merge indexes of any size in bounded memory.
type Object ¶
func Unpack ¶ added in v0.6.0
func Unpack(ctx context.Context, pack []byte, external func(SHA) (Type, []byte, error)) ([]Object, error)
Unpack reads the whole pack and returns its objects with every delta resolved. The pack may be thin: external resolves the base of a ref delta that the pack does not hold.
type Pack ¶
type Pack struct {
// contains filtered or unexported fields
}
func NewAt ¶ added in v0.10.0
NewAt returns a Pack that holds no index. It finds a name through the function that WithLookup sets, so a caller that indexes many packs in one structure reads each pack with no index of its own.
func NewPack ¶
NewPack checks the structure and the checksum of a v2 index before it trusts a byte of it.
func (*Pack) Bind ¶
Bind returns a view of the pack that reads through r and shares its index and object cache, so a request can bring its own context to the reads.
func (*Pack) CachedBytes ¶
CachedBytes is the size of the resolved objects the pack holds.
func (*Pack) GetDepth ¶
GetDepth is Get that also returns the length of the delta chain that produced the object; zero is a whole object.
func (*Pack) OnCacheChange ¶
func (p *Pack) OnCacheChange(f func())
OnCacheChange sets f to run, with no lock held, after an object enters the cache. Call it before the pack is shared.