diff options
author | David Turner <dturner@twopensource.com> | 2016-04-15 15:19:09 -0400 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-04-18 11:46:05 -0700 |
commit | 771dcaaee911d3cf2460a750e60ce611950d027e (patch) | |
tree | fda7ebbe114974f5bb0a114fa239219642d112c4 /builtin/clone.c | |
parent | fa16ec8aaa3247e8bd271b1728f6b59df1649194 (diff) | |
download | git-dt/http-fetch-limit-advertisement.tar.gz |
clone: send refspec for single-branch clonesdt/http-fetch-limit-advertisement
For single-branch clones (when we know in advance what the remote
branch name will be), send a refspec so that the server doesn't
tell us about any other refs.
Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/clone.c')
-rw-r--r-- | builtin/clone.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index ebced775df..7540e1027e 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -1017,7 +1017,21 @@ int cmd_clone(int argc, const char **argv, const char *prefix) if (transport->smart_options && !option_depth) transport->smart_options->check_self_contained_and_connected = 1; - refs = transport_get_remote_refs(transport, NULL, 0); + if (option_single_branch && option_branch) { + struct refspec branch_refspec = {0}; + + if (starts_with(option_branch, "refs/")) { + branch_refspec.src = xstrdup(option_branch); + } else { + struct strbuf buf = STRBUF_INIT; + strbuf_addf(&buf, "refs/heads/%s", option_branch); + branch_refspec.src = strbuf_detach(&buf, NULL); + } + refs = transport_get_remote_refs(transport, &branch_refspec, 1); + free(branch_refspec.src); + } else { + refs = transport_get_remote_refs(transport, NULL, 0); + } if (refs) { mapped_refs = wanted_peer_refs(refs, refspec); |