Skip to content

Commit

Permalink
Merge branch 'nd/clone-single-fix' into maint
Browse files Browse the repository at this point in the history
"git clone --single-branch" to clone a single branch did not limit
the cloning to the specified branch.

* nd/clone-single-fix:
  clone: fix ref selection in --single-branch --branch=xxx
  • Loading branch information
Junio C Hamano committed Jul 11, 2012
2 parents c8382c1 + 0ec4b16 commit 4ac01b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
7 changes: 5 additions & 2 deletions builtin/clone.c
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down
7 changes: 6 additions & 1 deletion t/t5500-fetch-pack.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
'
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 4ac01b0

Please sign in to comment.