mirror of
https://github.com/dolthub/dolt.git
synced 2026-03-13 19:29:58 -05:00
Fixed concurrency bug with dolt_commit()
This commit is contained in:
@@ -231,21 +231,9 @@ func (ddb *DoltDB) NewPendingCommit(
|
||||
}
|
||||
roots.Staged = newstaged
|
||||
|
||||
ds, err := ddb.db.GetDataset(ctx, headRef.String())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
nomsHeadAddr, hasHead := ds.MaybeHeadAddr()
|
||||
var parents []hash.Hash
|
||||
if hasHead {
|
||||
parents = append(parents, nomsHeadAddr)
|
||||
}
|
||||
|
||||
for _, pc := range parentCommits {
|
||||
if pc.dCommit.Addr() != nomsHeadAddr {
|
||||
parents = append(parents, pc.dCommit.Addr())
|
||||
}
|
||||
parents = append(parents, pc.dCommit.Addr())
|
||||
}
|
||||
|
||||
commitOpts := datas.CommitOptions{Parents: parents, Meta: cm}
|
||||
|
||||
@@ -141,15 +141,29 @@ func doltCommit(ctx *sql.Context,
|
||||
tx *DoltTransaction,
|
||||
commit *doltdb.PendingCommit,
|
||||
workingSet *doltdb.WorkingSet,
|
||||
hash hash.Hash,
|
||||
currHash hash.Hash,
|
||||
) (*doltdb.WorkingSet, *doltdb.Commit, error) {
|
||||
headRef, err := workingSet.Ref().ToHeadRef()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
cm, err := tx.dbData.Ddb.ResolveCommitRef(ctx, headRef)
|
||||
// TODO: branch not found?
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
// TODO: dumb to resolve just to get a hash, wasted effort
|
||||
headHash, err := cm.HashOf()
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
commit.CommitOptions.Parents = append(append([]hash.Hash{}, headHash), commit.CommitOptions.Parents...)
|
||||
|
||||
workingSet = workingSet.ClearMerge()
|
||||
newCommit, err := tx.dbData.Ddb.CommitWithWorkingSet(ctx, headRef, tx.workingSetRef, commit, workingSet, hash, tx.getWorkingSetMeta(ctx))
|
||||
newCommit, err := tx.dbData.Ddb.CommitWithWorkingSet(ctx, headRef, tx.workingSetRef, commit, workingSet, currHash, tx.getWorkingSetMeta(ctx))
|
||||
return workingSet, newCommit, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user