3 test_description='test submodule ref store api'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
10 RUN="test-tool ref-store submodule:sub"
12 test_expect_success 'setup' '
17 git checkout -b new-main
21 test_expect_success 'pack_refs() not allowed' '
22 test_must_fail $RUN pack-refs 3
25 test_expect_success 'peel_ref(new-tag)' '
26 git -C sub rev-parse HEAD >expected &&
27 git -C sub tag -a -m new-tag new-tag HEAD &&
28 $RUN peel-ref refs/tags/new-tag >actual &&
29 test_cmp expected actual
32 test_expect_success 'create_symref() not allowed' '
33 test_must_fail $RUN create-symref FOO refs/heads/main nothing
36 test_expect_success 'delete_refs() not allowed' '
37 test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
40 test_expect_success 'rename_refs() not allowed' '
41 test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main
44 test_expect_success 'for_each_ref(refs/heads/)' '
45 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
46 cat >expected <<-\EOF &&
50 test_cmp expected actual
53 test_expect_success 'for_each_ref() is sorted' '
54 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
55 sort actual > expected &&
56 test_cmp expected actual
59 test_expect_success 'resolve_ref(main)' '
60 SHA1=`git -C sub rev-parse main` &&
61 echo "$SHA1 refs/heads/main 0x0" >expected &&
62 $RUN resolve-ref refs/heads/main 0 >actual &&
63 test_cmp expected actual
66 test_expect_success 'verify_ref(new-main)' '
67 $RUN verify-ref refs/heads/new-main
70 test_expect_success 'for_each_reflog()' '
71 $RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
72 cat >expected <<-\EOF &&
75 refs/heads/new-main 0x0
77 test_cmp expected actual
80 test_expect_success 'for_each_reflog_ent()' '
81 $RUN for-each-reflog-ent HEAD >actual &&
82 head -n1 actual | grep first &&
83 tail -n2 actual | head -n1 | grep main.to.new
86 test_expect_success 'for_each_reflog_ent_reverse()' '
87 $RUN for-each-reflog-ent-reverse HEAD >actual &&
88 head -n1 actual | grep main.to.new &&
89 tail -n2 actual | head -n1 | grep first
92 test_expect_success 'reflog_exists(HEAD)' '
93 $RUN reflog-exists HEAD
96 test_expect_success 'delete_reflog() not allowed' '
97 test_must_fail $RUN delete-reflog HEAD
100 test_expect_success 'create-reflog() not allowed' '
101 test_must_fail $RUN create-reflog HEAD 1