49634157bf66e9e7d3b31edd94380678a1ade163
1#!/bin/sh
2
3test_description='test git checkout --to'
4
5. ./test-lib.sh
6
7test_expect_success 'setup' '
8 test_commit init
9'
10
11test_expect_success 'checkout --to not updating paths' '
12 test_must_fail git checkout --to -- init.t
13'
14
15test_expect_success 'checkout --to an existing worktree' '
16 mkdir existing &&
17 test_must_fail git checkout --detach --to existing master
18'
19
20test_expect_success 'checkout --to a new worktree' '
21 git checkout --to here master &&
22 (
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
29 )
30'
31
32test_expect_success 'checkout --to a new worktree from a subdir' '
33 (
34 mkdir sub &&
35 cd sub &&
36 git checkout --detach --to here master &&
37 cd here &&
38 test_cmp ../../init.t init.t
39 )
40'
41
42test_expect_success 'checkout --to from a linked checkout' '
43 (
44 cd here &&
45 git checkout --to nested-here master &&
46 cd nested-here &&
47 git fsck
48 )
49'
50
51test_expect_success 'checkout --to a new worktree creating new branch' '
52 git checkout --to there -b newmaster master &&
53 (
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
60 )
61'
62
63test_done