checkout: support checking out into a new working directory
[git/mjg.git] / t / t2025-checkout-to.sh
blob49634157bf66e9e7d3b31edd94380678a1ade163
1 #!/bin/sh
3 test_description='test git checkout --to'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 test_commit init
11 test_expect_success 'checkout --to not updating paths' '
12 test_must_fail git checkout --to -- init.t
15 test_expect_success 'checkout --to an existing worktree' '
16 mkdir existing &&
17 test_must_fail git checkout --detach --to existing master
20 test_expect_success 'checkout --to a new worktree' '
21 git checkout --to here master &&
23 cd here &&
24 test_cmp ../init.t init.t &&
25 git symbolic-ref HEAD >actual &&
26 echo refs/heads/master >expect &&
27 test_cmp expect actual &&
28 git fsck
32 test_expect_success 'checkout --to a new worktree from a subdir' '
34 mkdir sub &&
35 cd sub &&
36 git checkout --detach --to here master &&
37 cd here &&
38 test_cmp ../../init.t init.t
42 test_expect_success 'checkout --to from a linked checkout' '
44 cd here &&
45 git checkout --to nested-here master &&
46 cd nested-here &&
47 git fsck
51 test_expect_success 'checkout --to a new worktree creating new branch' '
52 git checkout --to there -b newmaster master &&
54 cd there &&
55 test_cmp ../init.t init.t &&
56 git symbolic-ref HEAD >actual &&
57 echo refs/heads/newmaster >expect &&
58 test_cmp expect actual &&
59 git fsck
63 test_done