packfile

package
v15.3.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 30, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func List

func List(objDir string) ([]string, error)

List returns the packfiles in objDir.

Types

type Bitmap

type Bitmap struct {
	// contains filtered or unexported fields
}

Bitmap represents a bitmap as used in a packfile .bitmap file.

func ReadEWAH

func ReadEWAH(r io.Reader) (*Bitmap, error)

ReadEWAH parses an EWAH-compressed bitmap into a *Bitmap.

func (*Bitmap) Scan

func (e *Bitmap) Scan(f func(int) error) error

Scan traverses the bitmap and calls f for each bit which is 1.

func (*Bitmap) Unpack

func (e *Bitmap) Unpack() error

Unpack expands e.raw, which is EWAH-compressed, into an uncompressed *big.Int.

type BitmapCommit

type BitmapCommit struct {
	OID string
	*Bitmap
	// contains filtered or unexported fields
}

BitmapCommit represents a bitmapped commit, i.e. a commit in the packfile plus a bitmap indicating which objects are reachable from that commit.

type Index

type Index struct {
	// ID is the packfile ID. For pack-123abc.idx, this would be 123abc.
	ID string

	// Objects holds the list of objects in the packfile in index order, i.e. sorted by OID
	Objects []*Object
	// Objects holds the list of objects in the packfile in packfile order, i.e. sorted by packfile offset
	PackfileOrder []*Object
	*IndexBitmap
	// contains filtered or unexported fields
}

Index is an in-memory representation of a packfile .idx file.

func ReadIndex

func ReadIndex(idxPath string) (*Index, error)

ReadIndex opens a packfile .idx file and loads its contents into memory. In doing so it will also open and read small amounts of data from the .pack file itself.

func (*Index) BuildPackfileOrder

func (idx *Index) BuildPackfileOrder()

BuildPackfileOrder populates the PackfileOrder field.

func (*Index) LabelObjectTypes

func (idx *Index) LabelObjectTypes() error

LabelObjectTypes tries to label each object in the index with its object type, using the packfile bitmap. Returns an error if there is no packfile .bitmap file.

func (*Index) LoadBitmap

func (idx *Index) LoadBitmap() error

LoadBitmap opens the .bitmap file corresponding to idx and loads it into memory. Returns an error if there is no .bitmap.

type IndexBitmap

type IndexBitmap struct {
	Commits *Bitmap
	Trees   *Bitmap
	Blobs   *Bitmap
	Tags    *Bitmap
	// contains filtered or unexported fields
}

IndexBitmap is the in-memory representation of a .bitmap file.

func (*IndexBitmap) BitmapCommit

func (ib *IndexBitmap) BitmapCommit(i int) (*BitmapCommit, error)

BitmapCommit retrieves a bitmap commit, along with its bitmap. If the bitmap is XOR-compressed this will decompress it.

func (*IndexBitmap) NumBitmapCommits

func (ib *IndexBitmap) NumBitmapCommits() int

NumBitmapCommits returns the number of indexed commits in the .bitmap file.

type Object

type Object struct {
	OID    string
	Type   ObjectType
	Offset uint64
}

Object represents a Git packfile index entry, optionally decorated with its object type.

func (Object) String

func (o Object) String() string

type ObjectType

type ObjectType byte

ObjectType is used to label index entries as commits, trees, blobs or tags.

const (
	// TUnknown is a sentinel indicating an object has not been labeled yet
	TUnknown ObjectType = iota
	// TBlob means Git blob
	TBlob
	// TCommit means Git commit
	TCommit
	// TTree means Git tree
	TTree
	// TTag means Git tag
	TTag
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL