Skip to content

Commit b65dc2c

Browse files
bk2204gitster
authored andcommitted
builtin/clone: initialize hash algorithm properly
When performing a clone, we don't know what hash algorithm the other end will support. Currently, we don't support fetching data belonging to a different algorithm, so we must know what algorithm the remote side is using in order to properly initialize the repository. We can know that only after fetching the refs, so if the remote side has any references, use that information to reinitialize the repository with the correct hash algorithm information. Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 7f60501 commit b65dc2c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

builtin/clone.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
12171217
refs = transport_get_remote_refs(transport, &ref_prefixes);
12181218

12191219
if (refs) {
1220+
int hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
1221+
1222+
/*
1223+
* Now that we know what algorithm the remote side is using,
1224+
* let's set ours to the same thing.
1225+
*/
1226+
initialize_repository_version(hash_algo);
1227+
repo_set_hash_algo(the_repository, hash_algo);
1228+
12201229
mapped_refs = wanted_peer_refs(refs, &remote->fetch);
12211230
/*
12221231
* transport_get_remote_refs() may return refs with null sha-1

0 commit comments

Comments
 (0)