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

Function getWants

remote.go:1057–1086  ·  view source on GitHub ↗
(localStorer storage.Storer, refs memory.ReferenceStorage, depth int)

Source from the content-addressed store, hash-verified

1055}
1056
1057func getWants(localStorer storage.Storer, refs memory.ReferenceStorage, depth int) ([]plumbing.Hash, error) {
1058 // If depth is anything other than 1 and the repo has shallow commits then just because we have the commit
1059 // at the reference doesn't mean that we don't still need to fetch the parents
1060 shallow := false
1061 if depth != 1 {
1062 if s, _ := localStorer.Shallow(); len(s) > 0 {
1063 shallow = true
1064 }
1065 }
1066
1067 wants := map[plumbing.Hash]bool{}
1068 for _, ref := range refs {
1069 hash := ref.Hash()
1070 exists, err := objectExists(localStorer, ref.Hash())
1071 if err != nil {
1072 return nil, err
1073 }
1074
1075 if !exists || shallow {
1076 wants[hash] = true
1077 }
1078 }
1079
1080 var result []plumbing.Hash
1081 for h := range wants {
1082 result = append(result, h)
1083 }
1084
1085 return result, nil
1086}
1087
1088func objectExists(s storer.EncodedObjectStorer, h plumbing.Hash) (bool, error) {
1089 _, err := s.EncodedObject(plumbing.AnyObject, h)

Callers 1

fetchMethod · 0.85

Calls 3

objectExistsFunction · 0.85
ShallowMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…