1package git23import "context"45// CatFileBlobOptions contains optional arguments for verifying the objects.6//7// Docs: https://git-scm.com/docs/git-cat-file#Documentation/git-cat-file.txt8type CatFileBlobOptions struct {9 CommandOptions10}1112// CatFileBlob returns the blob corresponding to the given revision of the repository.13func (r *Repository) CatFileBlob(ctx context.Context, rev string, opts ...CatFileBlobOptions) (*Blob, error) {14 var opt CatFileBlobOptions15 if len(opts) > 0 {16 opt = opts[0]17 }1819 // Type conversions work because all three option types share the same20 // underlying structure (CommandOptions only).21 rev, err := r.RevParse(ctx, rev, RevParseOptions(opt)) //nolint22 if err != nil {23 return nil, err24 }2526 typ, err := r.CatFileType(ctx, rev, CatFileTypeOptions(opt))27 if err != nil {28 return nil, err29 }3031 if typ != ObjectBlob {32 return nil, ErrNotBlob33 }3435 return &Blob{36 TreeEntry: &TreeEntry{37 mode: EntryBlob,38 typ: ObjectBlob,39 id: MustIDFromString(rev),40 parent: &Tree{41 repo: r,42 },43 },44 }, nil45}