]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Enable SHA-256 by default in breaking changes mode
authorbrian m. carlson <sandals@crustytoothpaste.net>
Fri, 20 Jun 2025 01:19:42 +0000 (01:19 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Jun 2025 14:17:37 +0000 (07:17 -0700)
Our document on breaking changes indicates that we intend to default to
SHA-256 in Git 3.0.  Since most people choose the default option, this
is an important security upgrade to our defaults.

To allow people to test this case, when WITH_BREAKING_CHANGES is set in
the configuration, build Git with SHA-256 as the default hash.  Update
the testsuite to reflect this configuration so that the tests pass.

Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
hash.h
t/test-lib.sh

diff --git a/hash.h b/hash.h
index 0e14cade4e4248793c8ba1899dc435578be36362..144b53b7d68fa0eab3781f3c59d56d321e2f6664 100644 (file)
--- a/hash.h
+++ b/hash.h
@@ -174,8 +174,14 @@ static inline void git_SHA256_Clone(git_SHA256_CTX *dst, const git_SHA256_CTX *s
 #define GIT_HASH_SHA256 2
 /* Number of algorithms supported (including unknown). */
 #define GIT_HASH_NALGOS (GIT_HASH_SHA256 + 1)
+
 /* Default hash algorithm if unspecified. */
+#ifdef WITH_BREAKING_CHANGES
+#define GIT_HASH_DEFAULT GIT_HASH_SHA256
+#else
 #define GIT_HASH_DEFAULT GIT_HASH_SHA1
+#endif
+
 /* Original hash algorithm. Implied for older data formats which don't specify. */
 #define GIT_HASH_ORIGINAL GIT_HASH_SHA1
 
index be7189067898fc433eb707f9127db84a36dcbf84..4cfa957e54c256be7441d4252018747f175d53da 100644 (file)
@@ -536,7 +536,12 @@ export GIT_COMMITTER_EMAIL GIT_COMMITTER_NAME
 export GIT_COMMITTER_DATE GIT_AUTHOR_DATE
 export EDITOR
 
-GIT_TEST_BUILTIN_HASH=sha1
+if test -n "$WITH_BREAKING_CHANGES"
+then
+       GIT_TEST_BUILTIN_HASH=sha256
+else
+       GIT_TEST_BUILTIN_HASH=sha1
+fi
 GIT_DEFAULT_HASH="${GIT_TEST_DEFAULT_HASH:-$GIT_TEST_BUILTIN_HASH}"
 export GIT_DEFAULT_HASH
 GIT_DEFAULT_REF_FORMAT="${GIT_TEST_DEFAULT_REF_FORMAT:-files}"