checkout: add test demonstrating regression with checkout -b on initial commit

Commit fa655d8411 (checkout: optimize "git checkout -b <new_branch>",
2018-08-16) introduced an unintentional change in behavior for 'checkout -b'
after doing 'clone --no-checkout'.  Add a test to demonstrate the changed
behavior to be used in a later patch to verify the fix.

Signed-off-by: Ben Peart <benpeart@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Ben Peart 2019-01-23 15:02:00 -05:00 коммит произвёл Junio C Hamano
Родитель 60129c61e5
Коммит 91e3d7ca9b
1 изменённых файлов: 9 добавлений и 0 удалений

Просмотреть файл

@ -198,4 +198,13 @@ test_expect_success 'checkout -B to the current branch works' '
test_dirty_mergeable
'
test_expect_failure 'checkout -b after clone --no-checkout does a checkout of HEAD' '
git init src &&
test_commit -C src a &&
rev="$(git -C src rev-parse HEAD)" &&
git clone --no-checkout src dest &&
git -C dest checkout "$rev" -b branch &&
test_path_is_file dest/a.t
'
test_done