aboutsummaryrefslogtreecommitdiffstats
path: root/storage/memory/storage.go
diff options
context:
space:
mode:
authorJeremy Stribling <strib@alum.mit.edu>2017-11-28 11:14:09 -0800
committerJeremy Stribling <strib@alum.mit.edu>2017-11-28 11:23:52 -0800
commitcbab840ef28888c2e85112b3b48294f7333ec187 (patch)
tree9fbd8da724791193905635a4ed789c6ddf8f39c5 /storage/memory/storage.go
parent83e7046d0c1ce12f5394a1d5a4e28cad32aa666d (diff)
downloadgo-git-cbab840ef28888c2e85112b3b48294f7333ec187.tar.gz
dotgit: add CheckAndSetReference tests
Diffstat (limited to 'storage/memory/storage.go')
-rw-r--r--storage/memory/storage.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/storage/memory/storage.go b/storage/memory/storage.go
index 69394af..c9306ee 100644
--- a/storage/memory/storage.go
+++ b/storage/memory/storage.go
@@ -204,16 +204,17 @@ func (r ReferenceStorage) SetReference(ref *plumbing.Reference) error {
}
func (r ReferenceStorage) CheckAndSetReference(ref, old *plumbing.Reference) error {
- if ref != nil {
- if old != nil {
- tmp := r[ref.Name()]
- if tmp != nil && tmp.Hash() != old.Hash() {
- return ErrRefHasChanged
- }
- }
- r[ref.Name()] = ref
+ if ref == nil {
+ return nil
}
+ if old != nil {
+ tmp := r[ref.Name()]
+ if tmp != nil && tmp.Hash() != old.Hash() {
+ return ErrRefHasChanged
+ }
+ }
+ r[ref.Name()] = ref
return nil
}