aboutsummaryrefslogtreecommitdiffstats
path: root/repository/gogit.go
diff options
context:
space:
mode:
authorMichael Muré <batolettre@gmail.com>2020-12-08 13:15:21 +0100
committerMichael Muré <batolettre@gmail.com>2020-12-08 13:15:21 +0100
commit71e1303234ef227851998f08c98c7c69670c9966 (patch)
treea2a72ec276992aa4628d418d68a99e49f40d1ef5 /repository/gogit.go
parentbe6e653f1566f5812e7c4442927eee02963dfb68 (diff)
downloadgit-bug-71e1303234ef227851998f08c98c7c69670c9966.tar.gz
repo: simpler clock mutex locking
Diffstat (limited to 'repository/gogit.go')
-rw-r--r--repository/gogit.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/repository/gogit.go b/repository/gogit.go
index 0d34c00a..741982aa 100644
--- a/repository/gogit.go
+++ b/repository/gogit.go
@@ -604,6 +604,9 @@ func (repo *GoGitRepo) ListCommits(ref string) ([]Hash, error) {
// GetOrCreateClock return a Lamport clock stored in the Repo.
// If the clock doesn't exist, it's created.
func (repo *GoGitRepo) GetOrCreateClock(name string) (lamport.Clock, error) {
+ repo.clocksMutex.Lock()
+ defer repo.clocksMutex.Unlock()
+
c, err := repo.getClock(name)
if err == nil {
return c, nil
@@ -612,9 +615,6 @@ func (repo *GoGitRepo) GetOrCreateClock(name string) (lamport.Clock, error) {
return nil, err
}
- repo.clocksMutex.Lock()
- defer repo.clocksMutex.Unlock()
-
c, err = lamport.NewPersistedClock(repo.localStorage, name+"-clock")
if err != nil {
return nil, err
@@ -625,9 +625,6 @@ func (repo *GoGitRepo) GetOrCreateClock(name string) (lamport.Clock, error) {
}
func (repo *GoGitRepo) getClock(name string) (lamport.Clock, error) {
- repo.clocksMutex.Lock()
- defer repo.clocksMutex.Unlock()
-
if c, ok := repo.clocks[name]; ok {
return c, nil
}