Revision ec445074e0ac4d6003acd21c512c43c8fdb8be86 authored by Junio C Hamano on 12 March 2014, 18:04:11 UTC, committed by Junio C Hamano on 13 March 2014, 21:22:20 UTC
The original description talked only about what it does.  Instead,
start it with the purpose of the command, i.e. what it is used for,
and then mention what it does to achieve that goal.

Clarify what <start>, <url> and <end> means in the context of the
overall purpose of the command.

Describe the extended syntax of <end> parameter that is used when
the local branch name is different from the branch name at the
repository the changes are published.

Helped-by: Eric Sunshine
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5aae66b
Raw File
t5706-clone-branch.sh
#!/bin/sh

test_description='clone --branch option'
. ./test-lib.sh

check_HEAD() {
	echo refs/heads/"$1" >expect &&
	git symbolic-ref HEAD >actual &&
	test_cmp expect actual
}

check_file() {
	echo "$1" >expect &&
	test_cmp expect file
}

test_expect_success 'setup' '
	mkdir parent &&
	(cd parent && git init &&
	 echo one >file && git add file && git commit -m one &&
	 git checkout -b two &&
	 echo two >file && git add file && git commit -m two &&
	 git checkout master) &&
	mkdir empty &&
	(cd empty && git init)
'

test_expect_success 'vanilla clone chooses HEAD' '
	git clone parent clone &&
	(cd clone &&
	 check_HEAD master &&
	 check_file one
	)
'

test_expect_success 'clone -b chooses specified branch' '
	git clone -b two parent clone-two &&
	(cd clone-two &&
	 check_HEAD two &&
	 check_file two
	)
'

test_expect_success 'clone -b sets up tracking' '
	(cd clone-two &&
	 echo origin >expect &&
	 git config branch.two.remote >actual &&
	 echo refs/heads/two >>expect &&
	 git config branch.two.merge >>actual &&
	 test_cmp expect actual
	)
'

test_expect_success 'clone -b does not munge remotes/origin/HEAD' '
	(cd clone-two &&
	 echo refs/remotes/origin/master >expect &&
	 git symbolic-ref refs/remotes/origin/HEAD >actual &&
	 test_cmp expect actual
	)
'

test_expect_success 'clone -b with bogus branch' '
	test_must_fail git clone -b bogus parent clone-bogus
'

test_expect_success 'clone -b not allowed with empty repos' '
	test_must_fail git clone -b branch empty clone-branch-empty
'

test_done
back to top