Documentation
¶
Overview ¶
Package gitobj reads git objects as the store holds them: the exact bytes git takes the SHA-1 of, "<kind> <size>\x00<content>", under a key.GitSHA1 key. It knows the framing, the hash, and the links one object holds to others, which is all the store needs: it does not check an object the way git fsck does. See architecture/git-objects.md.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrMalformed means a payload is not a git object the store can walk. ErrMalformed = errors.New("gitobj: malformed object") // ErrMismatch means a payload does not hash to the key it was given under. ErrMismatch = errors.New("gitobj: payload does not match its key") // ErrCollision means a payload carries the marks of a SHA-1 collision attack. // Its SHA-1 says nothing about it, so it must not be stored under one. ErrCollision = errors.New("gitobj: SHA-1 collision attack detected") )
Functions ¶
func Encode ¶
Encode frames content as an object of the given kind: the bytes a store holds, and the bytes git takes the SHA-1 of.
func KeyOf ¶
KeyOf returns the key of a payload: its SHA-1, as NewGitSHA1 lays it out. It does not look at the frame. A payload that carries the marks of a collision attack has no key, and gets ErrCollision.
func Verify ¶
Verify reports whether data is the object k names: not a collision, hashing to k, and framed as a git object. It leaves the content alone. git does not parse an object it only reaches as a file, and neither does the store: an object that will not parse is refused by the walk that has to read it (Links), which comes before a reference to it is accepted, and by nothing short of that.
Types ¶
type Kind ¶
type Kind uint8
Kind is what git calls an object's type.
type Link ¶
Link is one object's reference to another. Leaf says what the referring object knows of the target: it is a blob, which has no links, so a walk may count it without reading it. Git's own walks trust an entry's mode the same way.
func Links ¶
Links returns the objects a payload refers to, in the order it names them: a commit's tree and then its parents, a tree's entries, a tag's target. A blob has none. A tree entry that holds a submodule's commit is no link, since that commit lives in another repository; git does not need it here either.