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

Method CheckAndSetReference

storage/memory/storage.go:256–269  ·  view source on GitHub ↗
(ref, old *plumbing.Reference)

Source from the content-addressed store, hash-verified

254}
255
256func (r ReferenceStorage) CheckAndSetReference(ref, old *plumbing.Reference) error {
257 if ref == nil {
258 return nil
259 }
260
261 if old != nil {
262 tmp := r[ref.Name()]
263 if tmp != nil && tmp.Hash() != old.Hash() {
264 return storage.ErrReferenceHasChanged
265 }
266 }
267 r[ref.Name()] = ref
268 return nil
269}
270
271func (r ReferenceStorage) Reference(n plumbing.ReferenceName) (*plumbing.Reference, error) {
272 ref, ok := r[n]

Callers

nothing calls this directly

Calls 2

NameMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected