diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2012-06-22 16:35:47 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-06-22 14:16:34 -0700 |
commit | 0ec4b1650ccac48513f8cfb00d0778ba1d3e8fca (patch) | |
tree | 6eb9e150867cb774caf7aa4399ac91e49ddd4967 | |
parent | Git 1.7.10.5 (diff) | |
download | tgif-0ec4b1650ccac48513f8cfb00d0778ba1d3e8fca.tar.xz |
clone: fix ref selection in --single-branch --branch=xxx
- do not fetch HEAD
- do not also fetch refs following "xxx"
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/clone.c | 7 | ||||
-rwxr-xr-x | t/t5500-fetch-pack.sh | 7 |
2 files changed, 11 insertions, 3 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index a4d8d25ee3..f86aaf18f7 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -433,8 +433,11 @@ static struct ref *wanted_peer_refs(const struct ref *refs, if (!option_branch) remote_head = guess_remote_head(head, refs, 0); - else - remote_head = find_remote_branch(refs, option_branch); + else { + local_refs = NULL; + tail = &local_refs; + remote_head = copy_ref(find_remote_branch(refs, option_branch)); + } if (!remote_head && option_branch) warning(_("Could not find remote branch %s to clone."), diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 1d1ca98588..e80a2af348 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -125,6 +125,11 @@ test_expect_success 'single branch object count' ' test_cmp expected count.singlebranch ' +test_expect_success 'single given branch clone' ' + git clone --single-branch --branch A "file://$(pwd)/." branch-a && + test_must_fail git --git-dir=branch-a/.git rev-parse origin/B +' + test_expect_success 'clone shallow' ' git clone --no-single-branch --depth 2 "file://$(pwd)/." shallow ' @@ -276,7 +281,7 @@ test_expect_success 'clone shallow with --branch' ' ' test_expect_success 'clone shallow object count' ' - echo "in-pack: 12" > count3.expected && + echo "in-pack: 6" > count3.expected && GIT_DIR=shallow3/.git git count-objects -v | grep "^in-pack" > count3.actual && test_cmp count3.expected count3.actual |