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

Method Hash

plumbing/memory.go:20–26  ·  view source on GitHub ↗

Hash returns the object Hash, the hash is calculated on-the-fly the first time it's called, in all subsequent calls the same Hash is returned even if the type or the content have changed. The Hash is only generated if the size of the content is exactly the object size.

()

Source from the content-addressed store, hash-verified

18// if the type or the content have changed. The Hash is only generated if the
19// size of the content is exactly the object size.
20func (o *MemoryObject) Hash() Hash {
21 if o.h == ZeroHash && int64(len(o.cont)) == o.sz {
22 o.h = ComputeHash(o.t, o.cont)
23 }
24
25 return o.h
26}
27
28// Type returns the ObjectType
29func (o *MemoryObject) Type() ObjectType { return o.t }

Calls 1

ComputeHashFunction · 0.85