aboutsummaryrefslogtreecommitdiffstats
path: root/storage
diff options
context:
space:
mode:
authorTaru Karttunen <taruti@taruti.net>2017-09-19 14:27:05 +0300
committerJeremy Stribling <strib@alum.mit.edu>2017-11-27 11:43:01 -0800
commitc4766ff1a7227de77bba488a8481f332ea8c1667 (patch)
treeae6c465e58678125877dcf23227bb155b2969c9e /storage
parent3834e571da171844efecc4e26fd89082419079a1 (diff)
downloadgo-git-c4766ff1a7227de77bba488a8481f332ea8c1667.tar.gz
Document Lock+Close usage
Diffstat (limited to 'storage')
-rw-r--r--storage/filesystem/internal/dotgit/dotgit.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/storage/filesystem/internal/dotgit/dotgit.go b/storage/filesystem/internal/dotgit/dotgit.go
index e60ffca..cb3adc8 100644
--- a/storage/filesystem/internal/dotgit/dotgit.go
+++ b/storage/filesystem/internal/dotgit/dotgit.go
@@ -294,6 +294,10 @@ func (d *DotGit) SetRef(r, old *plumbing.Reference) error {
defer ioutil.CheckClose(f, &err)
+ // Lock is unlocked by the deferred Close above. This is because Unlock
+ // does not imply a fsync and thus there would be a race between
+ // Unlock+Close and other concurrent writers. Adding Sync to go-billy
+ // could work, but this is better (and avoids superfluous syncs).
err = f.Lock()
if err != nil {
return err