Documentation
¶
Index ¶
- func BinToHex(objectFormat ObjectFormat, sha, out []byte) []byte
- func DiscardFull(rd *bufio.Reader, discard int64) error
- func EnsureValidGitRepository(ctx context.Context, repoPath string) error
- func IsErrObjectNotFound(err error) bool
- func ParseCatFileTreeLine(objectFormat ObjectFormat, rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fname, sha []byte, n int, err error)
- func ReadBatchLine(rd *bufio.Reader) (sha []byte, typ string, size int64, err error)
- func ReadTagObjectID(rd *bufio.Reader, size int64) (string, error)
- func ReadTreeID(rd *bufio.Reader, size int64) (string, error)
- type Batch
- type ErrObjectNotFound
- type ObjectFormat
- type WriteCloserError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BinToHex ¶
func BinToHex(objectFormat ObjectFormat, sha, out []byte) []byte
BinToHex converts a binary hash into a hex encoded one. Input and output can be the same byte slice to support in-place conversion without allocations.
func DiscardFull ¶
DiscardFull discards the requested amount of bytes from the buffered reader regardless of its internal limit.
func EnsureValidGitRepository ¶
EnsureValidGitRepository runs `git rev-parse` in the repository path to make sure the directory is a valid git repository. This avoids git cat-file hanging indefinitely when invoked in invalid paths.
func IsErrObjectNotFound ¶
IsErrObjectNotFound reports whether err is an ErrObjectNotFound
func ParseCatFileTreeLine ¶
func ParseCatFileTreeLine(objectFormat ObjectFormat, rd *bufio.Reader, modeBuf, fnameBuf, shaBuf []byte) (mode, fname, sha []byte, n int, err error)
ParseCatFileTreeLine reads an entry from a tree in a cat-file --batch stream and avoids allocations where possible. Each line is composed of: <mode-in-ascii> SP <fname> NUL <binary HASH>
func ReadBatchLine ¶
ReadBatchLine reads the header line from cat-file --batch. It expects the format "<oid> SP <type> SP <size> LF" and leaves the reader positioned at the start of the object contents (which must be fully consumed by the caller).
func ReadTagObjectID ¶
ReadTagObjectID reads a tag object ID hash from a cat-file --batch stream, throwing away the rest.
Types ¶
type Batch ¶
type Batch interface {
Writer() WriteCloserError
Reader() *bufio.Reader
Close()
}
func NewBatch ¶
NewBatch creates a new cat-file --batch process for the provided repository path. The returned Batch must be closed once the caller has finished with it.
type ErrObjectNotFound ¶
type ErrObjectNotFound struct {
ID string
}
ErrObjectNotFound indicates that the requested object could not be read from cat-file
func (ErrObjectNotFound) Error ¶
func (err ErrObjectNotFound) Error() string
type ObjectFormat ¶
type ObjectFormat interface {
FullLength() int
}
ObjectFormat abstracts the minimal information needed from git.ObjectFormat.
type WriteCloserError ¶
type WriteCloserError interface {
io.WriteCloser
CloseWithError(err error) error
}
WriteCloserError wraps an io.WriteCloser with an additional CloseWithError function
Source Files
¶
- batch.go
- reader.go