mirror of
https://github.com/git-for-windows/git.git
synced 2026-03-25 19:43:19 -05:00
Merge branch 'nd/clone-detached' into next
* nd/clone-detached: clone: fix up delay cloning conditions
This commit is contained in:
@@ -630,12 +630,13 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
const struct ref *remote_head_points_at;
|
||||
const struct ref *our_head_points_at;
|
||||
struct ref *mapped_refs;
|
||||
const struct ref *ref;
|
||||
struct strbuf key = STRBUF_INIT, value = STRBUF_INIT;
|
||||
struct strbuf branch_top = STRBUF_INIT, reflog_msg = STRBUF_INIT;
|
||||
struct transport *transport = NULL;
|
||||
const char *src_ref_prefix = "refs/heads/";
|
||||
struct remote *remote;
|
||||
int err = 0;
|
||||
int err = 0, complete_refs_before_fetch = 1;
|
||||
|
||||
struct refspec *refspec;
|
||||
const char *fetch_pattern;
|
||||
@@ -815,15 +816,22 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
mapped_refs = refs ? wanted_peer_refs(refs, refspec) : NULL;
|
||||
|
||||
/*
|
||||
* mapped_refs may be updated if transport-helper is used so
|
||||
* we need fetch it early because remote_head code below
|
||||
* relies on it.
|
||||
* transport_get_remote_refs() may return refs with null sha-1
|
||||
* in mapped_refs (see struct transport->get_refs_list
|
||||
* comment). In that case we need fetch it early because
|
||||
* remote_head code below relies on it.
|
||||
*
|
||||
* for normal clones, transport_get_remote_refs() should
|
||||
* return reliable ref set, we can delay cloning until after
|
||||
* remote HEAD check.
|
||||
*/
|
||||
if (!is_local && remote->foreign_vcs && refs)
|
||||
for (ref = refs; ref; ref = ref->next)
|
||||
if (is_null_sha1(ref->old_sha1)) {
|
||||
complete_refs_before_fetch = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!is_local && !complete_refs_before_fetch && refs)
|
||||
transport_fetch_refs(transport, mapped_refs);
|
||||
|
||||
if (refs) {
|
||||
@@ -855,7 +863,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
|
||||
|
||||
if (is_local)
|
||||
clone_local(path, git_dir);
|
||||
else if (refs && !remote->foreign_vcs)
|
||||
else if (refs && complete_refs_before_fetch)
|
||||
transport_fetch_refs(transport, mapped_refs);
|
||||
|
||||
update_remote_refs(refs, mapped_refs, remote_head_points_at,
|
||||
|
||||
@@ -204,13 +204,11 @@ static int do_push(const char *repo, int flags)
|
||||
url_nr = remote->url_nr;
|
||||
}
|
||||
if (url_nr) {
|
||||
const char *configured_foreign_vcs = remote->foreign_vcs;
|
||||
for (i = 0; i < url_nr; i++) {
|
||||
struct transport *transport =
|
||||
transport_get(remote, url[i]);
|
||||
if (push_with_options(transport, flags))
|
||||
errs++;
|
||||
remote->foreign_vcs = configured_foreign_vcs;
|
||||
}
|
||||
} else {
|
||||
struct transport *transport =
|
||||
|
||||
@@ -899,10 +899,8 @@ struct transport *transport_get(struct remote *remote, const char *url)
|
||||
|
||||
while (is_urlschemechar(p == url, *p))
|
||||
p++;
|
||||
if (!prefixcmp(p, "::")) {
|
||||
if (!prefixcmp(p, "::"))
|
||||
helper = xstrndup(url, p - url);
|
||||
remote->foreign_vcs = helper;
|
||||
}
|
||||
}
|
||||
|
||||
if (helper) {
|
||||
@@ -944,7 +942,6 @@ struct transport *transport_get(struct remote *remote, const char *url)
|
||||
char *handler = xmalloc(len + 1);
|
||||
handler[len] = 0;
|
||||
strncpy(handler, url, len);
|
||||
remote->foreign_vcs = handler;
|
||||
transport_helper_init(ret, handler);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user