mirror of
https://github.com/dolthub/dolt.git
synced 2026-04-25 03:34:05 -05:00
Simplify logic in doCommit as per Raf's suggestions. Define ref.EmptyRef variable.
This commit is contained in:
@@ -46,17 +46,11 @@ func (ds *dataStoreCommon) commitWithParents(v types.Value, p SetOfCommit) bool
|
||||
func (ds *dataStoreCommon) doCommit(commit Commit) bool {
|
||||
currentRootRef := ds.Root()
|
||||
|
||||
// Note: |currentHead| may be different from ds.head and *must* be consistent with currentRootRef.
|
||||
// If currentRoot or currentHead is nil, then any commit is allowed.
|
||||
emptyRef := ref.Ref{}
|
||||
dsHeadRef := emptyRef
|
||||
if ds.head != nil {
|
||||
dsHeadRef = ds.head.Ref()
|
||||
}
|
||||
|
||||
var currentHead Commit
|
||||
if currentRootRef != emptyRef {
|
||||
if currentRootRef == dsHeadRef {
|
||||
// First commit is always fast-foward.
|
||||
if currentRootRef != ref.EmptyRef {
|
||||
// Note: |currentHead| may be different from ds.head and *must* be consistent with currentRootRef.
|
||||
var currentHead Commit
|
||||
if ds.head != nil && currentRootRef == ds.head.Ref() {
|
||||
currentHead = *ds.head
|
||||
} else {
|
||||
currentHead = *commitFromRef(currentRootRef, ds)
|
||||
|
||||
+2
-1
@@ -14,7 +14,8 @@ import (
|
||||
|
||||
var (
|
||||
// In the future we will allow different digest types, so this will get more complicated. For now sha1 is fine.
|
||||
pattern = regexp.MustCompile("^sha1-([0-9a-f]{40})$")
|
||||
pattern = regexp.MustCompile("^sha1-([0-9a-f]{40})$")
|
||||
EmptyRef = Ref{}
|
||||
)
|
||||
|
||||
type Sha1Digest [sha1.Size]byte
|
||||
|
||||
Reference in New Issue
Block a user