diff options
author | Paulo Gomes <pjbgf@linux.com> | 2023-04-11 21:00:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-04-11 21:00:47 +0100 |
commit | d5b1afd3cc786e56a90cec910b79815ed3b23cc7 (patch) | |
tree | 4e0b93ea480fdea37761d2e879a073ce6f5c1747 /plumbing/format/commitgraph/encoder.go | |
parent | ce62f3e9ff86270538a514a68d3bd5563a733e3b (diff) | |
parent | 8e8281008ee98e9864fa9597be3e16aaecdf9891 (diff) | |
download | go-git-d5b1afd3cc786e56a90cec910b79815ed3b23cc7.tar.gz |
Merge pull request #707 from pjbgf/experimental-sha256
*: Add support for initializing SHA256 repositories
Diffstat (limited to 'plumbing/format/commitgraph/encoder.go')
-rw-r--r-- | plumbing/format/commitgraph/encoder.go | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/plumbing/format/commitgraph/encoder.go b/plumbing/format/commitgraph/encoder.go index bcf7d03..f61025b 100644 --- a/plumbing/format/commitgraph/encoder.go +++ b/plumbing/format/commitgraph/encoder.go @@ -1,7 +1,6 @@ package commitgraph
import (
- "crypto"
"io"
"github.com/go-git/go-git/v5/plumbing"
@@ -17,7 +16,7 @@ type Encoder struct { // NewEncoder returns a new stream encoder that writes to w.
func NewEncoder(w io.Writer) *Encoder {
- h := hash.New(crypto.SHA1)
+ h := hash.New(hash.CryptoType)
mw := io.MultiWriter(w, h)
return &Encoder{mw, h}
}
@@ -31,7 +30,7 @@ func (e *Encoder) Encode(idx Index) error { hashToIndex, fanout, extraEdgesCount := e.prepare(idx, hashes)
chunkSignatures := [][]byte{oidFanoutSignature, oidLookupSignature, commitDataSignature}
- chunkSizes := []uint64{4 * 256, uint64(len(hashes)) * 20, uint64(len(hashes)) * 36}
+ chunkSizes := []uint64{4 * 256, uint64(len(hashes)) * hash.Size, uint64(len(hashes)) * 36}
if extraEdgesCount > 0 {
chunkSignatures = append(chunkSignatures, extraEdgeListSignature)
chunkSizes = append(chunkSizes, uint64(extraEdgesCount)*4)
@@ -183,6 +182,6 @@ func (e *Encoder) encodeExtraEdges(extraEdges []uint32) (err error) { }
func (e *Encoder) encodeChecksum() error {
- _, err := e.Write(e.hash.Sum(nil)[:20])
+ _, err := e.Write(e.hash.Sum(nil)[:hash.Size])
return err
}
|