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

Function expandPartialHash

repository.go:1860–1886  ·  view source on GitHub ↗
(st storer.EncodedObjectStorer, prefix []byte)

Source from the content-addressed store, hash-verified

1858}
1859
1860func expandPartialHash(st storer.EncodedObjectStorer, prefix []byte) (hashes []plumbing.Hash) {
1861 // The fast version is implemented by storage/filesystem.ObjectStorage.
1862 type fastIter interface {
1863 HashesWithPrefix(prefix []byte) ([]plumbing.Hash, error)
1864 }
1865 if fi, ok := st.(fastIter); ok {
1866 h, err := fi.HashesWithPrefix(prefix)
1867 if err != nil {
1868 return nil
1869 }
1870 return h
1871 }
1872
1873 // Slow path.
1874 iter, err := st.IterEncodedObjects(plumbing.AnyObject)
1875 if err != nil {
1876 return nil
1877 }
1878 iter.ForEach(func(obj plumbing.EncodedObject) error {
1879 h := obj.Hash()
1880 if bytes.HasPrefix(h[:], prefix) {
1881 hashes = append(hashes, h)
1882 }
1883 return nil
1884 })
1885 return
1886}

Callers 1

resolveHashPrefixMethod · 0.85

Calls 4

HashesWithPrefixMethod · 0.65
IterEncodedObjectsMethod · 0.65
ForEachMethod · 0.65
HashMethod · 0.65

Tested by

no test coverage detected