Skip to content

Add catfile convenience methods

I was investigating some odd cat-file related errors in Sentry: https://sentry.gitlap.com/gitlab/gitaly-production/issues/111032/

CommitService::TreeEntry
rpc error: code = Internal desc = TreeEntry: read info line: EOF

I couldn't reproduce it but I did find out that our git cat-file --batch handling code is more complex than I would like. This MR introduces a convenience class catfile.Batch which can be used to fetch raw git objects.

% go doc gitlab.com/gitlab-org/gitaly/internal/git/catfile.Batch
type Batch struct {
	// Has unexported fields.
}
    Batch abstracts 'git cat-file --batch' and 'git cat-file --batch-check'. It
    lets you retrieve object metadata and raw objects from a Git repo.

    A Batch instance can only serve single request at a time. If you want to use
    it across multiple goroutines you need to add your own locking.


func New(ctx context.Context, repo *pb.Repository) (*Batch, error)
func (c *Batch) Blob(revspec string) (io.Reader, error)
func (c *Batch) Commit(revspec string) (io.Reader, error)
func (c *Batch) Info(revspec string) (*ObjectInfo, error)
func (c *Batch) Tree(revspec string) (io.Reader, error)
Edited by GitLab Release Tools Bot

Merge request reports

Loading