Fast implementation of Git in pure Go

Add a little bit more of documentation

+43 -14
+3 -1
headers.go
··· 2 3 // ExtraHeader represents an extra header in a Git object. 4 type ExtraHeader struct { 5 - Key string 6 Value []byte 7 }
··· 2 3 // ExtraHeader represents an extra header in a Git object. 4 type ExtraHeader struct { 5 + // Key represents the header key. 6 + Key string 7 + // Value represents the header value. 8 Value []byte 9 }
+8 -3
ident.go
··· 12 13 // Ident represents a Git identity (author/committer/tagger). 14 type Ident struct { 15 - Name []byte 16 - Email []byte 17 - WhenUnix int64 18 OffsetMinutes int32 19 } 20
··· 12 13 // Ident represents a Git identity (author/committer/tagger). 14 type Ident struct { 15 + // Name represents the person's name. 16 + Name []byte 17 + // Email represents the person's email. 18 + Email []byte 19 + // WhenUnix represents the timestamp as a Unix time. 20 + // This value is in UTC. 21 + WhenUnix int64 22 + // The timezone offset in minutes. 23 OffsetMinutes int32 24 } 25
+2
obj.go
··· 38 39 // Object represents a Git object. 40 type Object interface { 41 ObjectType() ObjectType 42 } 43 ··· 45 // one read from storage. 46 type StoredObject interface { 47 Object 48 Hash() Hash 49 } 50
··· 38 39 // Object represents a Git object. 40 type Object interface { 41 + // ObjectType returns the object's type. 42 ObjectType() ObjectType 43 } 44 ··· 46 // one read from storage. 47 type StoredObject interface { 48 Object 49 + // Hash returns the object's hash. 50 Hash() Hash 51 } 52
+13 -5
obj_commit.go
··· 8 9 // Commit represents a Git commit object. 10 type Commit struct { 11 - Tree Hash 12 - Parents []Hash 13 - Author Ident 14 - Committer Ident 15 - Message []byte 16 ExtraHeaders []ExtraHeader 17 } 18
··· 8 9 // Commit represents a Git commit object. 10 type Commit struct { 11 + // Tree represents the tree hash referenced by the commit. 12 + Tree Hash 13 + // Parents represents the parent commit hashes. 14 + // Commits that have 0 parents are root commits. 15 + // Commits that have >= 2 parents are merge commits. 16 + Parents []Hash 17 + // Author represents the author of the commit. 18 + Author Ident 19 + // Committer represents the committer of the commit. 20 + Committer Ident 21 + // Message represents the commit message. 22 + Message []byte 23 + // ExtraHeaders holds any extra headers present in the commit. 24 ExtraHeaders []ExtraHeader 25 } 26
+11 -4
obj_tag.go
··· 8 9 // Tag represents a Git annotated tag object. 10 type Tag struct { 11 - Target Hash 12 TargetType ObjectType 13 - Name []byte 14 - Tagger *Ident 15 - Message []byte 16 } 17 18 // StoredTag represents a tag stored in the object database. 19 type StoredTag struct {
··· 8 9 // Tag represents a Git annotated tag object. 10 type Tag struct { 11 + // Target represents the hash of the object being tagged. 12 + Target Hash 13 + // TargetType represents the type of the object being tagged. 14 TargetType ObjectType 15 + // Name represents the name of the tag. 16 + Name []byte 17 + // Tagger represents the identity of the tagger. 18 + Tagger *Ident 19 + // Message represents the tag message. 20 + Message []byte 21 } 22 + 23 + // TODO: ExtraHeaders and signatures 24 25 // StoredTag represents a tag stored in the object database. 26 type StoredTag struct {
+6 -1
obj_tree.go
··· 9 10 // Tree represents a Git tree object. 11 type Tree struct { 12 Entries []TreeEntry 13 } 14 ··· 41 42 // TreeEntry represents a single entry in a Git tree. 43 type TreeEntry struct { 44 Mode FileMode 45 Name []byte 46 - ID Hash 47 } 48 49 // ObjectType returns the object type of the tree.
··· 9 10 // Tree represents a Git tree object. 11 type Tree struct { 12 + // Entries represents the entries in the tree. 13 Entries []TreeEntry 14 } 15 ··· 42 43 // TreeEntry represents a single entry in a Git tree. 44 type TreeEntry struct { 45 + // Mode represents the file mode of the entry. 46 Mode FileMode 47 + // Name represents the name of the entry. 48 Name []byte 49 + // ID represents the hash of the entry. This is typically 50 + // either a blob or a tree. 51 + ID Hash 52 } 53 54 // ObjectType returns the object type of the tree.