diff options
| author | 2026-03-06 04:31:54 +0800 | |
|---|---|---|
| committer | 2026-03-06 04:36:57 +0800 | |
| commit | 17eed9abe9743699b561bd5cf13a0eecbe2e27b8 (patch) | |
| tree | 684a2692ae648f2d9ac00e362cae0b8d0a215895 /format/commitgraph/bloom/settings.go | |
| parent | README: Learning from git, got, and git9 (diff) | |
| signature | No signature | |
format/commitgraph/bloom: Add commit-graph bloom filters
Diffstat (limited to 'format/commitgraph/bloom/settings.go')
| -rw-r--r-- | format/commitgraph/bloom/settings.go | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/format/commitgraph/bloom/settings.go b/format/commitgraph/bloom/settings.go new file mode 100644 index 00000000..5aa122a9 --- /dev/null +++ b/format/commitgraph/bloom/settings.go @@ -0,0 +1,31 @@ +package bloom + +import "encoding/binary" + +// Settings describe the changed-paths Bloom filter parameters stored in +// commit-graph BDAT chunks. +// +// Obviously, they must match the repository's commit-graph settings to +// interpret filters correctly. +type Settings struct { + HashVersion uint32 + NumHashes uint32 + BitsPerEntry uint32 + MaxChangePaths uint32 +} + +// ParseSettings reads Bloom filter settings from a BDAT chunk header. +func ParseSettings(bdat []byte) (*Settings, error) { + if len(bdat) < DataHeaderSize { + return nil, ErrInvalid + } + + settings := &Settings{ + HashVersion: binary.BigEndian.Uint32(bdat[0:4]), + NumHashes: binary.BigEndian.Uint32(bdat[4:8]), + BitsPerEntry: binary.BigEndian.Uint32(bdat[8:12]), + MaxChangePaths: DefaultMaxChange, + } + + return settings, nil +} |
