Skip to content

Commit 9412759

Browse files
bk2204gitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 61e2a70 commit 9412759

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

config.mak.dev

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ DEVELOPER_CFLAGS += -Wstrict-prototypes
1717
DEVELOPER_CFLAGS += -Wunused
1818
DEVELOPER_CFLAGS += -Wvla
1919

20+
DEVELOPER_CFLAGS += -DENABLE_SHA256
21+
2022
ifndef COMPILER_FEATURES
2123
COMPILER_FEATURES := $(shell ./detect-compiler $(CC))
2224
endif

repository.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ void repo_set_gitdir(struct repository *repo,
8989
void repo_set_hash_algo(struct repository *repo, int hash_algo)
9090
{
9191
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
9296
}
9397

9498
/*

0 commit comments

Comments
 (0)