diff options
| author | 2025-11-16 00:00:00 +0000 | |
|---|---|---|
| committer | 2025-11-16 00:00:00 +0000 | |
| commit | edd37bb4fd3aa08eda39303fd5628a554a8c3aeb (patch) | |
| tree | 9b438c2e0b64f880cc57c90446fcec8768e7730b /obj_commit.go | |
| parent | Move config to its own package (diff) | |
| signature | ||
Separate stored object types from types that the user is expected to construct.
Diffstat (limited to 'obj_commit.go')
| -rw-r--r-- | obj_commit.go | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/obj_commit.go b/obj_commit.go index f1616fba..c3a4e5db 100644 --- a/obj_commit.go +++ b/obj_commit.go @@ -6,9 +6,8 @@ import ( "fmt" ) -// Commit mirrors the structure of a Git commit object. +// Commit represents a Git commit object. type Commit struct { - Hash Hash Tree Hash Parents []Hash Author Ident @@ -17,15 +16,26 @@ type Commit struct { ExtraHeaders []ExtraHeader } +// StoredCommit represents a commit stored in the object database. +type StoredCommit struct { + Commit + hash Hash +} + +// Hash returns the hash of the stored commit. +func (sCommit *StoredCommit) Hash() Hash { + return sCommit.hash +} + // ObjectType allows Commit to satisfy the Object interface. func (commit *Commit) ObjectType() ObjectType { _ = commit return ObjectTypeCommit } -func parseCommit(id Hash, body []byte, repo *Repository) (*Commit, error) { - c := new(Commit) - c.Hash = id +func parseCommit(id Hash, body []byte, repo *Repository) (*StoredCommit, error) { + c := new(StoredCommit) + c.hash = id i := 0 for i < len(body) { rel := bytes.IndexByte(body[i:], '\n') |
