config: move a few helper functions up
[git.git] / t / t2028-worktree-move.sh
blob8298aaf97f706ea796a12614acafd19636aeaa70
1 #!/bin/sh
3 test_description='test git worktree move, remove, lock and unlock'
5 . ./test-lib.sh
7 test_expect_success 'setup' '
8 test_commit init &&
9 git worktree add source &&
10 git worktree list --porcelain | grep "^worktree" >actual &&
11 cat <<-EOF >expected &&
12 worktree $(pwd)
13 worktree $(pwd)/source
14 EOF
15 test_cmp expected actual
18 test_expect_success 'lock main worktree' '
19 test_must_fail git worktree lock .
22 test_expect_success 'lock linked worktree' '
23 git worktree lock --reason hahaha source &&
24 echo hahaha >expected &&
25 test_cmp expected .git/worktrees/source/locked
28 test_expect_success 'lock linked worktree from another worktree' '
29 rm .git/worktrees/source/locked &&
30 git worktree add elsewhere &&
31 git -C elsewhere worktree lock --reason hahaha ../source &&
32 echo hahaha >expected &&
33 test_cmp expected .git/worktrees/source/locked
36 test_expect_success 'lock worktree twice' '
37 test_must_fail git worktree lock source &&
38 echo hahaha >expected &&
39 test_cmp expected .git/worktrees/source/locked
42 test_expect_success 'lock worktree twice (from the locked worktree)' '
43 test_must_fail git -C source worktree lock . &&
44 echo hahaha >expected &&
45 test_cmp expected .git/worktrees/source/locked
48 test_expect_success 'unlock main worktree' '
49 test_must_fail git worktree unlock .
52 test_expect_success 'unlock linked worktree' '
53 git worktree unlock source &&
54 test_path_is_missing .git/worktrees/source/locked
57 test_expect_success 'unlock worktree twice' '
58 test_must_fail git worktree unlock source &&
59 test_path_is_missing .git/worktrees/source/locked
62 test_done