MCPcopy Create free account
hub / github.com/go-git/go-git / CheckAndSetReference

Method CheckAndSetReference

storage/transactional/reference.go:38–57  ·  view source on GitHub ↗

SetReference honors the storer.ReferenceStorer interface.

(ref, old *plumbing.Reference)

Source from the content-addressed store, hash-verified

36
37// SetReference honors the storer.ReferenceStorer interface.
38func (r *ReferenceStorage) CheckAndSetReference(ref, old *plumbing.Reference) error {
39 if old == nil {
40 return r.SetReference(ref)
41 }
42
43 tmp, err := r.temporal.Reference(old.Name())
44 if err == plumbing.ErrReferenceNotFound {
45 tmp, err = r.ReferenceStorer.Reference(old.Name())
46 }
47
48 if err != nil {
49 return err
50 }
51
52 if tmp.Hash() != old.Hash() {
53 return storage.ErrReferenceHasChanged
54 }
55
56 return r.SetReference(ref)
57}
58
59// Reference honors the storer.ReferenceStorer interface.
60func (r ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) {

Callers 1

Calls 4

SetReferenceMethod · 0.95
ReferenceMethod · 0.65
NameMethod · 0.65
HashMethod · 0.65

Tested by 1