Only use SHA256 feature when git >= 2.42 (#28466)

And fix some comments
This commit is contained in:
wxiaoguang 2023-12-14 16:51:05 +08:00 committed by GitHub
parent 52046b934d
commit 9947af639c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 12 deletions

View file

@ -20,7 +20,6 @@ type ObjectID interface {
Type() ObjectFormat
}
/* SHA1 */
type Sha1Hash [20]byte
func (h *Sha1Hash) String() string {
@ -38,7 +37,7 @@ func NewSha1() *Sha1Hash {
return &Sha1Hash{}
}
// generic implementations
// NewHash is for generic implementations
func NewHash(hash string) (ObjectID, error) {
hash = strings.ToLower(hash)
switch hash {
@ -73,7 +72,6 @@ func genericIDFromString(h ObjectFormat, s string) (ObjectID, error) {
return h.NewID(b)
}
// utils
func IDFromString(hexHash string) (ObjectID, error) {
switch len(hexHash) {
case 40:
@ -101,7 +99,7 @@ func IsEmptyCommitID(commitID string) bool {
return id.IsZero()
}
// HashInterface is a struct that will generate a Hash
// HasherInterface is a struct that will generate a Hash
type HasherInterface interface {
hash.Hash
@ -127,7 +125,7 @@ func ComputeHash(hashType ObjectFormat, t ObjectType, content []byte) ObjectID {
return h.HashSum()
}
// Sum generates a SHA1 for the provided hash
// HashSum generates a SHA1 for the provided hash
func (h *Sha1Hasher) HashSum() ObjectID {
var sha1 Sha1Hash
copy(sha1[:], h.Hash.Sum(nil))