Skip to content

Commit ca6daa1

Browse files
bk2204gitster
authored andcommitted
hash: add a constant for the default hash algorithm
Right now, SHA-1 is the default hash algorithm in Git. However, this may change in the future. We have many places in our code that use the SHA-1 constant to indicate the default hash if none is specified, but it will end up being more practical to specify this explicitly and clearly using a constant for whatever the default hash algorithm is. Then, if we decide to change it in the future, we can simply replace the constant representing the default with a new value. For these reasons, introduce GIT_HASH_DEFAULT to represent the default hash algorithm. Signed-off-by: brian m. carlson <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16bd9f2 commit ca6daa1

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

hash.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,8 @@ static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *s
174174
#define GIT_HASH_SHA256 2
175175
/* Number of algorithms supported (including unknown). */
176176
#define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
177+
/* Default hash algorithm if unspecified. */
178+
#define GIT_HASH_DEFAULT GIT_HASH_SHA1
177179

178180
/* "sha1", big-endian */
179181
#define GIT_SHA1_FORMAT_ID 0x73686131

0 commit comments

Comments
 (0)