diff options
author | Junio C Hamano <gitster@pobox.com> | 2022-02-09 14:21:01 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2022-02-09 14:21:01 -0800 |
commit | d991df4bf6259bc53223feb71957c961b7b8fa84 (patch) | |
tree | 962a3b5ce0484140d4b24c726f2794d53cd28601 /builtin | |
parent | Merge branch 'jt/sparse-checkout-leading-dir-fix' (diff) | |
parent | clone: support unusual remote ref configurations (diff) | |
download | tgif-d991df4bf6259bc53223feb71957c961b7b8fa84.tar.xz |
Merge branch 'jt/clone-not-quite-empty'
Cloning from a repository that does not yet have any branches or
tags but has other refs resulted in a "remote transport reported
error", which has been corrected.
* jt/clone-not-quite-empty:
clone: support unusual remote ref configurations
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/clone.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index b19925f373..9c29093b35 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -863,7 +863,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) const struct ref *refs, *remote_head; struct ref *remote_head_points_at = NULL; const struct ref *our_head_points_at; - struct ref *mapped_refs; + struct ref *mapped_refs = NULL; const struct ref *ref; struct strbuf key = STRBUF_INIT; struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT; @@ -1185,7 +1185,10 @@ int cmd_clone(int argc, const char **argv, const char *prefix) refs = transport_get_remote_refs(transport, &transport_ls_refs_options); - if (refs) { + if (refs) + mapped_refs = wanted_peer_refs(refs, &remote->fetch); + + if (mapped_refs) { int hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport)); /* @@ -1194,8 +1197,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix) */ initialize_repository_version(hash_algo, 1); repo_set_hash_algo(the_repository, hash_algo); - - mapped_refs = wanted_peer_refs(refs, &remote->fetch); /* * transport_get_remote_refs() may return refs with null sha-1 * in mapped_refs (see struct transport->get_refs_list @@ -1241,7 +1242,6 @@ int cmd_clone(int argc, const char **argv, const char *prefix) option_branch, remote_name); warning(_("You appear to have cloned an empty repository.")); - mapped_refs = NULL; our_head_points_at = NULL; remote_head_points_at = NULL; remote_head = NULL; @@ -1272,7 +1272,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (is_local) clone_local(path, git_dir); - else if (refs && complete_refs_before_fetch) { + else if (mapped_refs && complete_refs_before_fetch) { if (transport_fetch_refs(transport, mapped_refs)) die(_("remote transport reported error")); } |