@matheusbsbs / matheus-bagliano / commits / 9412759925
Fork 0

repository: require a build flag to use SHA-256

At this point, SHA-256 support is experimental and some behavior may change. To avoid surprising unsuspecting users, require a build flag, ENABLE_SHA256, to allow use of a non-SHA-1 algorithm. Enable this flag by default when the DEVELOPER make flag is set so that contributors can test this case adequately. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

brian m. carlson committed Feb 22, 2020 at 20:17 UTC 94127599252d85e85571ecde740ea97e59e4bede
2 files changed +6
config.mak.dev
+2
@@ -17,6 +17,8 @@ DEVELOPER_CFLAGS += -Wstrict-prototypes
17 DEVELOPER_CFLAGS += -Wunused
18 DEVELOPER_CFLAGS += -Wvla
19
20 +DEVELOPER_CFLAGS += -DENABLE_SHA256
21 +
22 ifndef COMPILER_FEATURES
23 COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
24 endif
repository.c
+4
@@ -89,6 +89,10 @@ void repo_set_gitdir(struct repository *repo,
89 void repo_set_hash_algo(struct repository *repo, int hash_algo)
90 {
91 repo->hash_algo = &hash_algos[hash_algo];
92 +#ifndef ENABLE_SHA256
93 + if (hash_algo != GIT_HASH_SHA1)
94 + die(_("The hash algorithm %s is not supported in this build."), repo->hash_algo->name);
95 +#endif
96 }
97
98 /*