t7800: improve test descriptions with empty arguments
[alt-git.git] / t / t1407-worktree-ref-store.sh
blob05b1881c5911780b53a3d882dbe1a4dfae0034d8
1 #!/bin/sh
3 test_description='test worktree ref store api'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 RWT="test-tool ref-store worktree:wt"
12 RMAIN="test-tool ref-store worktree:main"
14 test_expect_success 'setup' '
15 test_commit first &&
16 git worktree add -b wt-main wt &&
18 cd wt &&
19 test_commit second
23 test_expect_success 'resolve_ref(<shared-ref>)' '
24 SHA1=`git rev-parse main` &&
25 echo "$SHA1 refs/heads/main 0x0" >expected &&
26 $RWT resolve-ref refs/heads/main 0 >actual &&
27 test_cmp expected actual &&
28 $RMAIN resolve-ref refs/heads/main 0 >actual &&
29 test_cmp expected actual
32 test_expect_success 'resolve_ref(<per-worktree-ref>)' '
33 SHA1=`git -C wt rev-parse HEAD` &&
34 echo "$SHA1 refs/heads/wt-main 0x1" >expected &&
35 $RWT resolve-ref HEAD 0 >actual &&
36 test_cmp expected actual &&
38 SHA1=`git rev-parse HEAD` &&
39 echo "$SHA1 refs/heads/main 0x1" >expected &&
40 $RMAIN resolve-ref HEAD 0 >actual &&
41 test_cmp expected actual
44 test_expect_success 'create_symref(FOO, refs/heads/main)' '
45 $RWT create-symref FOO refs/heads/main nothing &&
46 echo refs/heads/main >expected &&
47 git -C wt symbolic-ref FOO >actual &&
48 test_cmp expected actual &&
50 $RMAIN create-symref FOO refs/heads/wt-main nothing &&
51 echo refs/heads/wt-main >expected &&
52 git symbolic-ref FOO >actual &&
53 test_cmp expected actual
56 # Some refs (refs/bisect/*, pseudorefs) are kept per worktree, so they should
57 # only appear in the for-each-reflog output if it is called from the correct
58 # worktree, which is exercised in this test. This test is poorly written (and
59 # therefore marked REFFILES) for mulitple reasons: 1) it creates invalidly
60 # formatted log entres. 2) it uses direct FS access for creating the reflogs. 3)
61 # PSEUDO-WT and refs/bisect/random do not create reflogs by default, so it is
62 # not testing a realistic scenario.
63 test_expect_success REFFILES 'for_each_reflog()' '
64 echo $ZERO_OID > .git/logs/PSEUDO-MAIN &&
65 mkdir -p .git/logs/refs/bisect &&
66 echo $ZERO_OID > .git/logs/refs/bisect/random &&
68 echo $ZERO_OID > .git/worktrees/wt/logs/PSEUDO-WT &&
69 mkdir -p .git/worktrees/wt/logs/refs/bisect &&
70 echo $ZERO_OID > .git/worktrees/wt/logs/refs/bisect/wt-random &&
72 $RWT for-each-reflog | cut -d" " -f 2- | sort >actual &&
73 cat >expected <<-\EOF &&
74 HEAD 0x1
75 PSEUDO-WT 0x0
76 refs/bisect/wt-random 0x0
77 refs/heads/main 0x0
78 refs/heads/wt-main 0x0
79 EOF
80 test_cmp expected actual &&
82 $RMAIN for-each-reflog | cut -d" " -f 2- | sort >actual &&
83 cat >expected <<-\EOF &&
84 HEAD 0x1
85 PSEUDO-MAIN 0x0
86 refs/bisect/random 0x0
87 refs/heads/main 0x0
88 refs/heads/wt-main 0x0
89 EOF
90 test_cmp expected actual
93 test_done