usage: trace2 BUG() invocations
[git] / t / t1407-worktree-ref-store.sh
1 #!/bin/sh
2
3 test_description='test worktree ref store api'
4
5 . ./test-lib.sh
6
7 RWT="test-tool ref-store worktree:wt"
8 RMAIN="test-tool ref-store worktree:main"
9
10 test_expect_success 'setup' '
11         test_commit first &&
12         git worktree add -b wt-master wt &&
13         (
14                 cd wt &&
15                 test_commit second
16         )
17 '
18
19 test_expect_success 'resolve_ref(<shared-ref>)' '
20         SHA1=`git rev-parse master` &&
21         echo "$SHA1 refs/heads/master 0x0" >expected &&
22         $RWT resolve-ref refs/heads/master 0 >actual &&
23         test_cmp expected actual &&
24         $RMAIN resolve-ref refs/heads/master 0 >actual &&
25         test_cmp expected actual
26 '
27
28 test_expect_success 'resolve_ref(<per-worktree-ref>)' '
29         SHA1=`git -C wt rev-parse HEAD` &&
30         echo "$SHA1 refs/heads/wt-master 0x1" >expected &&
31         $RWT resolve-ref HEAD 0 >actual &&
32         test_cmp expected actual &&
33
34         SHA1=`git rev-parse HEAD` &&
35         echo "$SHA1 refs/heads/master 0x1" >expected &&
36         $RMAIN resolve-ref HEAD 0 >actual &&
37         test_cmp expected actual
38 '
39
40 test_expect_success 'create_symref(FOO, refs/heads/master)' '
41         $RWT create-symref FOO refs/heads/master nothing &&
42         echo refs/heads/master >expected &&
43         git -C wt symbolic-ref FOO >actual &&
44         test_cmp expected actual &&
45
46         $RMAIN create-symref FOO refs/heads/wt-master nothing &&
47         echo refs/heads/wt-master >expected &&
48         git symbolic-ref FOO >actual &&
49         test_cmp expected actual
50 '
51
52 test_expect_success 'for_each_reflog()' '
53         echo $ZERO_OID > .git/logs/PSEUDO-MAIN &&
54         mkdir -p     .git/logs/refs/bisect &&
55         echo $ZERO_OID > .git/logs/refs/bisect/random &&
56
57         echo $ZERO_OID > .git/worktrees/wt/logs/PSEUDO-WT &&
58         mkdir -p     .git/worktrees/wt/logs/refs/bisect &&
59         echo $ZERO_OID > .git/worktrees/wt/logs/refs/bisect/wt-random &&
60
61         $RWT for-each-reflog | cut -d" " -f 2- | sort >actual &&
62         cat >expected <<-\EOF &&
63         HEAD 0x1
64         PSEUDO-WT 0x0
65         refs/bisect/wt-random 0x0
66         refs/heads/master 0x0
67         refs/heads/wt-master 0x0
68         EOF
69         test_cmp expected actual &&
70
71         $RMAIN for-each-reflog | cut -d" " -f 2- | sort >actual &&
72         cat >expected <<-\EOF &&
73         HEAD 0x1
74         PSEUDO-MAIN 0x0
75         refs/bisect/random 0x0
76         refs/heads/master 0x0
77         refs/heads/wt-master 0x0
78         EOF
79         test_cmp expected actual
80 '
81
82 test_done