3 test_description
='test git checkout --to'
7 test_expect_success
'setup' '
11 test_expect_success
'checkout --to not updating paths' '
12 test_must_fail git checkout --to -- init.t
15 test_expect_success
'checkout --to a new worktree' '
16 git rev-parse HEAD >expect &&
17 git checkout --to here master &&
20 test_cmp ../init.t init.t &&
21 test_must_fail git symbolic-ref HEAD &&
22 git rev-parse HEAD >actual &&
23 test_cmp ../expect actual &&
28 test_expect_success
'checkout --to from a linked checkout' '
31 git checkout --to nested-here master
37 test_expect_success
'checkout --to a new worktree creating new branch' '
38 git checkout --to there -b newmaster master &&
41 test_cmp ../init.t init.t &&
42 git symbolic-ref HEAD >actual &&
43 echo refs/heads/newmaster >expect &&
44 test_cmp expect actual &&
49 test_expect_success
'detach if the same branch is already checked out' '
52 git checkout newmaster &&
53 test_must_fail git symbolic-ref HEAD
57 test_expect_success
'not detach on re-checking out current branch' '
60 git checkout newmaster &&
65 test_expect_success
'checkout --to from a bare repo' '
67 git clone --bare . bare &&
69 git checkout --to ../there2 master
73 test_expect_success
'checkout from a bare repo without --to' '
76 test_must_fail git checkout master