internal/git package should auto-detect the used object format
internal/git
assumes sha1 in a few places. We should make changes so it auto-detects if sha256 or sha1 hashes are used by the repository configuration.
Affected consts/functions
-
ValidateObjectID
: It assumes a length of 40 hexadecimal chars, but with sha256 this would be 64. -
ZeroOID
: This sentinel consist of 40 zeroes, but for sha256 it would be 64 zeroes -
EmptyTreeOID
: This sentinel is completely different between sha1 and sha256
Proposal
From: !4702 (comment 1026164756)
A repo would have a function that returns an object that complies with the following interface:
type ObjectIDType interface {
FromHex()
EmptyTreeID()
FromBytes()
}
objectIDType := repo.ObjectIDType()
objectIDType.FromHex(hex)
objectIDType.EmptyTreeID()
objectIDType.FromBytes()
Edited by Toon Claes