From 499669c144218704c0942860564325d76adb13e2 Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sat, 14 Jul 2018 06:42:13 +0200 Subject: each commit reference the very first set of ops (will be useful for fast access to lamport clock and ordering) --- bug/bug.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'bug/bug.go') diff --git a/bug/bug.go b/bug/bug.go index 658d73e1..fc7c0c2a 100644 --- a/bug/bug.go +++ b/bug/bug.go @@ -18,6 +18,7 @@ type Bug struct { id uuid.UUID lastCommit util.Hash + root util.Hash // TODO: need a way to order bugs, probably a Lamport clock @@ -88,7 +89,7 @@ func (bug *Bug) Append(op Operation) { bug.staging.Append(op) } -// Write the staging area in Git move the operations to the packs +// Write the staging area in Git and move the operations to the packs func (bug *Bug) Commit(repo repository.Repo) error { if bug.staging.IsEmpty() { return nil @@ -100,9 +101,15 @@ func (bug *Bug) Commit(repo repository.Repo) error { return err } + root := bug.root + if root == "" { + root = hash + } + // Write a Git tree referencing this blob hash, err = repo.StoreTree(map[string]util.Hash{ - "ops": hash, + "ops": hash, // the last pack of ops + "root": root, // always the first pack of ops (might be the same) }) if err != nil { return err -- cgit