aboutsummaryrefslogtreecommitdiffstats
path: root/setup.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2025-07-21 09:14:25 -0700
committerJunio C Hamano <gitster@pobox.com>2025-07-21 09:14:25 -0700
commita636d395ff0b0ccecb4569c0fc80f7c55f2e5f2e (patch)
treefd758d24e1db2726312822e7f8e5d1ffcdd13444 /setup.c
parent90c0775e972847832ac8dfa6a14bc4c3abacd914 (diff)
parentc79bb70a2e7d9158ec165ea16ad45371cd6e350d (diff)
downloadgit-a636d395ff0b0ccecb4569c0fc80f7c55f2e5f2e.tar.gz
Merge branch 'bc/use-sha256-by-default-in-3.0'
Prepare to flip the default hash function to SHA-256. * bc/use-sha256-by-default-in-3.0: Enable SHA-256 by default in breaking changes mode help: add a build option for default hash t5300: choose the built-in hash outside of a repo t4042: choose the built-in hash outside of a repo t1007: choose the built-in hash outside of a repo t: default to compile-time default hash if not set setup: use the default algorithm to initialize repo format Use legacy hash for legacy formats builtin: use default hash when outside a repository hash: add a constant for the legacy hash algorithm hash: add a constant for the default hash algorithm
Diffstat (limited to 'setup.c')
-rw-r--r--setup.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/setup.c b/setup.c
index 18661fc048..6f52dab64c 100644
--- a/setup.c
+++ b/setup.c
@@ -836,9 +836,12 @@ static void init_repository_format(struct repository_format *format)
int read_repository_format(struct repository_format *format, const char *path)
{
clear_repository_format(format);
+ format->hash_algo = GIT_HASH_SHA1_LEGACY;
git_config_from_file(check_repo_format, path, format);
- if (format->version == -1)
+ if (format->version == -1) {
clear_repository_format(format);
+ format->hash_algo = GIT_HASH_SHA1_LEGACY;
+ }
return format->version;
}
@@ -2225,11 +2228,11 @@ void initialize_repository_version(int hash_algo,
* version will get adjusted by git-clone(1) once it has learned about
* the remote repository's format.
*/
- if (hash_algo != GIT_HASH_SHA1 ||
+ if (hash_algo != GIT_HASH_SHA1_LEGACY ||
ref_storage_format != REF_STORAGE_FORMAT_FILES)
target_version = GIT_REPO_VERSION_READ;
- if (hash_algo != GIT_HASH_SHA1 && hash_algo != GIT_HASH_UNKNOWN)
+ if (hash_algo != GIT_HASH_SHA1_LEGACY && hash_algo != GIT_HASH_UNKNOWN)
git_config_set("extensions.objectformat",
hash_algos[hash_algo].name);
else if (reinit)