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

Method calculateHash

utils/merkletrie/internal/fsnoder/dir.go:84–93  ·  view source on GitHub ↗

hash is calculated as the hash of "dir " plus the concatenation, for each child, of its name, a space and its hash. Children are sorted alphabetically before calculating the hash, so the result is unique.

()

Source from the content-addressed store, hash-verified

82// each child, of its name, a space and its hash. Children are sorted
83// alphabetically before calculating the hash, so the result is unique.
84func (d *dir) calculateHash() {
85 h := fnv.New64a()
86 h.Write([]byte("dir "))
87 for _, c := range d.children {
88 h.Write([]byte(c.Name()))
89 h.Write([]byte(" "))
90 h.Write(c.Hash())
91 }
92 d.hash = h.Sum([]byte{})
93}
94
95func (d *dir) Name() string {
96 return d.name

Callers 1

HashMethod · 0.95

Calls 4

SumMethod · 0.80
NameMethod · 0.65
HashMethod · 0.65
WriteMethod · 0.45

Tested by

no test coverage detected