(localStorer storage.Storer, refs memory.ReferenceStorage, depth int)
| 1055 | } |
| 1056 | |
| 1057 | func 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 | |
| 1088 | func objectExists(s storer.EncodedObjectStorer, h plumbing.Hash) (bool, error) { |
| 1089 | _, err := s.EncodedObject(plumbing.AnyObject, h) |
no test coverage detected
searching dependent graphs…