Git fork

Merge branch 'jc/clone-object-format-from-void'

"git clone" from an empty repository learned to propagate the
choice of the hash algorithm from the source repository to the
newly created repository.

* jc/clone-object-format-from-void:
clone: propagate object-format when cloning from void

+17 -5
+6 -5
builtin/clone.c
··· 914 int err = 0, complete_refs_before_fetch = 1; 915 int submodule_progress; 916 int filter_submodules = 0; 917 918 struct transport_ls_refs_options transport_ls_refs_options = 919 TRANSPORT_LS_REFS_OPTIONS_INIT; ··· 1302 } 1303 } 1304 1305 - if (mapped_refs) { 1306 - int hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport)); 1307 - 1308 /* 1309 * Now that we know what algorithm the remote side is using, 1310 * let's set ours to the same thing. 1311 */ 1312 - initialize_repository_version(hash_algo, 1); 1313 - repo_set_hash_algo(the_repository, hash_algo); 1314 /* 1315 * transport_get_remote_refs() may return refs with null sha-1 1316 * in mapped_refs (see struct transport->get_refs_list
··· 914 int err = 0, complete_refs_before_fetch = 1; 915 int submodule_progress; 916 int filter_submodules = 0; 917 + int hash_algo; 918 919 struct transport_ls_refs_options transport_ls_refs_options = 920 TRANSPORT_LS_REFS_OPTIONS_INIT; ··· 1303 } 1304 } 1305 1306 /* 1307 * Now that we know what algorithm the remote side is using, 1308 * let's set ours to the same thing. 1309 */ 1310 + hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport)); 1311 + initialize_repository_version(hash_algo, 1); 1312 + repo_set_hash_algo(the_repository, hash_algo); 1313 + 1314 + if (mapped_refs) { 1315 /* 1316 * transport_get_remote_refs() may return refs with null sha-1 1317 * in mapped_refs (see struct transport->get_refs_list
+11
t/t5702-protocol-v2.sh
··· 269 grep "warning: remote HEAD refers to nonexistent ref" stderr 270 ' 271 272 test_expect_success 'bare clone propagates unborn HEAD from non-empty repo' ' 273 test_when_finished "rm -rf file_unborn_parent file_unborn_child.git" && 274
··· 269 grep "warning: remote HEAD refers to nonexistent ref" stderr 270 ' 271 272 + test_expect_success 'clone propagates object-format from empty repo' ' 273 + test_when_finished "rm -fr src256 dst256" && 274 + 275 + echo sha256 >expect && 276 + git init --object-format=sha256 src256 && 277 + git clone src256 dst256 && 278 + git -C dst256 rev-parse --show-object-format >actual && 279 + 280 + test_cmp expect actual 281 + ' 282 + 283 test_expect_success 'bare clone propagates unborn HEAD from non-empty repo' ' 284 test_when_finished "rm -rf file_unborn_parent file_unborn_child.git" && 285