From dc5059bc3372941e2908739831188768335ac50b Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 24 Jan 2021 19:45:21 +0100 Subject: entity: more progress on merging and signing --- repository/common.go | 53 ---------------------------------------------------- 1 file changed, 53 deletions(-) (limited to 'repository/common.go') diff --git a/repository/common.go b/repository/common.go index 7fd7ae19..4cefbd9e 100644 --- a/repository/common.go +++ b/repository/common.go @@ -8,59 +8,6 @@ import ( "golang.org/x/crypto/openpgp/errors" ) -// nonNativeMerge is an implementation of a branch merge, for the case where -// the underlying git implementation doesn't support it natively. -func nonNativeMerge(repo RepoData, ref string, otherRef string, treeHashFn func() Hash) error { - commit, err := repo.ResolveRef(ref) - if err != nil { - return err - } - - otherCommit, err := repo.ResolveRef(otherRef) - if err != nil { - return err - } - - if commit == otherCommit { - // nothing to merge - return nil - } - - // fast-forward is possible if otherRef include ref - - otherCommits, err := repo.ListCommits(otherRef) - if err != nil { - return err - } - - fastForwardPossible := false - for _, hash := range otherCommits { - if hash == commit { - fastForwardPossible = true - break - } - } - - if fastForwardPossible { - return repo.UpdateRef(ref, otherCommit) - } - - // fast-forward is not possible, we need to create a merge commit - - // we need a Tree to make the commit, an empty Tree will do - emptyTreeHash, err := repo.StoreTree(nil) - if err != nil { - return err - } - - newHash, err := repo.StoreCommit(emptyTreeHash, commit, otherCommit) - if err != nil { - return err - } - - return repo.UpdateRef(ref, newHash) -} - // nonNativeListCommits is an implementation for ListCommits, for the case where // the underlying git implementation doesn't support if natively. func nonNativeListCommits(repo RepoData, ref string) ([]Hash, error) { -- cgit