MCPcopy
hub / github.com/go-git/go-git / checkAndUpdateReferenceStorerIfNeeded

Function checkAndUpdateReferenceStorerIfNeeded

repository.go:1164–1182  ·  view source on GitHub ↗
(
	s storer.ReferenceStorer, r, old *plumbing.Reference)

Source from the content-addressed store, hash-verified

1162}
1163
1164func checkAndUpdateReferenceStorerIfNeeded(
1165 s storer.ReferenceStorer, r, old *plumbing.Reference) (
1166 updated bool, err error) {
1167 p, err := s.Reference(r.Name())
1168 if err != nil && err != plumbing.ErrReferenceNotFound {
1169 return false, err
1170 }
1171
1172 // we use the string method to compare references, is the easiest way
1173 if err == plumbing.ErrReferenceNotFound || r.String() != p.String() {
1174 if err := s.CheckAndSetReference(r, old); err != nil {
1175 return false, err
1176 }
1177
1178 return true, nil
1179 }
1180
1181 return false, nil
1182}
1183
1184func updateReferenceStorerIfNeeded(
1185 s storer.ReferenceStorer, r *plumbing.Reference) (updated bool, err error) {

Callers 2

Calls 4

ReferenceMethod · 0.65
NameMethod · 0.65
StringMethod · 0.65
CheckAndSetReferenceMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…