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>
Nguyễn Thái Ngọc Duy committed
Jun 22, 2012 at 16:35 UTC
0ec4b1650ccac48513f8cfb00d0778ba1d3e8fca
2 files changed
+11
-3
builtin/clone.c
+5
-2
@@ -433,8 +433,11 @@ static struct ref *wanted_peer_refs(const struct ref *refs,
433
434
if (!option_branch)
435
remote_head = guess_remote_head(head, refs, 0);
436
- else
437
- remote_head = find_remote_branch(refs, option_branch);
436
+ else {
437
+ local_refs = NULL;
438
+ tail = &local_refs;
439
+ remote_head = copy_ref(find_remote_branch(refs, option_branch));
440
+ }
441
442
if (!remote_head && option_branch)
443
warning(_("Could not find remote branch %s to clone."),
t/t5500-fetch-pack.sh
+6
-1
@@ -125,6 +125,11 @@ test_expect_success 'single branch object count' '
125
test_cmp expected count.singlebranch
126
'
127
128
+test_expect_success 'single given branch clone' '
129
+ git clone --single-branch --branch A "file://$(pwd)/." branch-a &&
130
+ test_must_fail git --git-dir=branch-a/.git rev-parse origin/B
131
+'
132
+
133
test_expect_success 'clone shallow' '
134
git clone --no-single-branch --depth 2 "file://$(pwd)/." shallow
135
'
@@ -276,7 +281,7 @@ test_expect_success 'clone shallow with --branch' '
281
'
282
283
test_expect_success 'clone shallow object count' '
279
- echo "in-pack: 12" > count3.expected &&
284
+ echo "in-pack: 6" > count3.expected &&
285
GIT_DIR=shallow3/.git git count-objects -v |
286
grep "^in-pack" > count3.actual &&
287
test_cmp count3.expected count3.actual