Beispiel #1
0
func (t *treeFS) newDirNode(id *git.Oid) nodefs.Node {
	n := &dirNode{
		gitNode: gitNode{
			fs:   t,
			id:   id.Copy(),
			Node: nodefs.NewDefaultNode(),
		},
	}
	return n
}
Beispiel #2
0
func (t *treeFS) newLinkNode(id *git.Oid) (nodefs.Node, error) {
	n := &linkNode{
		gitNode: gitNode{
			fs:   t,
			id:   id.Copy(),
			Node: nodefs.NewDefaultNode(),
		},
	}

	blob, err := t.repo.LookupBlob(id)
	if err != nil {
		return nil, err
	}
	defer blob.Free()
	n.target = append([]byte{}, blob.Contents()...)
	return n, nil
}
Beispiel #3
0
func (t *treeFS) newBlobNode(id *git.Oid, mode git.Filemode) (nodefs.Node, error) {
	n := &blobNode{
		gitNode: gitNode{
			fs:   t,
			id:   id.Copy(),
			Node: nodefs.NewDefaultNode(),
		},
	}
	odb, err := t.repo.Odb()
	if err != nil {
		return nil, err
	}
	defer odb.Free()
	sz, _, err := odb.ReadHeader(id)
	if err != nil {
		return nil, err
	}

	n.size = sz
	n.mode = mode
	return n, nil
}