diff options
author | 2020-09-29 14:01:20 -0700 | |
---|---|---|
committer | 2020-09-29 14:01:20 -0700 | |
commit | b28919c7bcfabad81896070e6b7b66be8310e6a8 (patch) | |
tree | 304d19a2c97a33b316271952c1429163ace95438 /builtin | |
parent | Merge branch 'tb/bloom-improvements' (diff) | |
parent | builtin/clone: avoid failure with GIT_DEFAULT_HASH (diff) | |
download | tgif-b28919c7bcfabad81896070e6b7b66be8310e6a8.tar.xz |
Merge branch 'bc/clone-with-git-default-hash-fix'
"git clone" that clones from SHA-1 repository, while
GIT_DEFAULT_HASH set to use SHA-256 already, resulted in an
unusable repository that half-claims to be SHA-256 repository
with SHA-1 objects and refs. This has been corrected.
* bc/clone-with-git-default-hash-fix:
builtin/clone: avoid failure with GIT_DEFAULT_HASH
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/clone.c | 2 | ||||
-rw-r--r-- | builtin/init-db.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index fbfd6568cd..391aa41075 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -1233,7 +1233,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) * Now that we know what algorithm the remote side is using, * let's set ours to the same thing. */ - initialize_repository_version(hash_algo); + initialize_repository_version(hash_algo, 1); repo_set_hash_algo(the_repository, hash_algo); mapped_refs = wanted_peer_refs(refs, &remote->fetch); diff --git a/builtin/init-db.c b/builtin/init-db.c index cd3e760541..01bc648d41 100644 --- a/builtin/init-db.c +++ b/builtin/init-db.c @@ -179,7 +179,7 @@ static int needs_work_tree_config(const char *git_dir, const char *work_tree) return 1; } -void initialize_repository_version(int hash_algo) +void initialize_repository_version(int hash_algo, int reinit) { char repo_version_string[10]; int repo_version = GIT_REPO_VERSION; @@ -195,6 +195,8 @@ void initialize_repository_version(int hash_algo) if (hash_algo != GIT_HASH_SHA1) git_config_set("extensions.objectformat", hash_algos[hash_algo].name); + else if (reinit) + git_config_set_gently("extensions.objectformat", NULL); } static int create_default_files(const char *template_path, @@ -277,7 +279,7 @@ static int create_default_files(const char *template_path, free(ref); } - initialize_repository_version(fmt->hash_algo); + initialize_repository_version(fmt->hash_algo, 0); /* Check filemode trustability */ path = git_path_buf(&buf, "config"); |