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 &&
18 git tag -a -m new-tag new-tag HEAD
22 test_expect_success 'pack_refs() not allowed' '
23 test_must_fail $RUN pack-refs 3
26 test_expect_success 'create_symref() not allowed' '
27 test_must_fail $RUN create-symref FOO refs/heads/main nothing
30 test_expect_success 'delete_refs() not allowed' '
31 test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
34 test_expect_success 'rename_refs() not allowed' '
35 test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main
38 test_expect_success 'for_each_ref(refs/heads/)' '
39 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
40 cat >expected <<-\EOF &&
44 test_cmp expected actual
47 test_expect_success 'for_each_ref() is sorted' '
48 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
49 sort actual > expected &&
50 test_cmp expected actual
53 test_expect_success 'resolve_ref(main)' '
54 SHA1=`git -C sub rev-parse main` &&
55 echo "$SHA1 refs/heads/main 0x0" >expected &&
56 $RUN resolve-ref refs/heads/main 0 >actual &&
57 test_cmp expected actual
60 test_expect_success 'verify_ref(new-main)' '
61 $RUN verify-ref refs/heads/new-main
64 test_expect_success 'for_each_reflog()' '
65 $RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
66 cat >expected <<-\EOF &&
69 refs/heads/new-main 0x0
71 test_cmp expected actual
74 test_expect_success 'for_each_reflog_ent()' '
75 $RUN for-each-reflog-ent HEAD >actual &&
76 head -n1 actual | grep first &&
77 tail -n2 actual | head -n1 | grep main.to.new
80 test_expect_success 'for_each_reflog_ent_reverse()' '
81 $RUN for-each-reflog-ent-reverse HEAD >actual &&
82 head -n1 actual | grep main.to.new &&
83 tail -n2 actual | head -n1 | grep first
86 test_expect_success 'reflog_exists(HEAD)' '
87 $RUN reflog-exists HEAD
90 test_expect_success 'delete_reflog() not allowed' '
91 test_must_fail $RUN delete-reflog HEAD
94 test_expect_success 'create-reflog() not allowed' '
95 test_must_fail $RUN create-reflog HEAD 1