3 test_description
='test submodule ref store api'
7 RUN
="test-tool ref-store submodule:sub"
9 test_expect_success
'setup' '
14 git checkout -b new-master
18 test_expect_success
'pack_refs() not allowed' '
19 test_must_fail $RUN pack-refs 3
22 test_expect_success
'peel_ref(new-tag)' '
23 git -C sub rev-parse HEAD >expected &&
24 git -C sub tag -a -m new-tag new-tag HEAD &&
25 $RUN peel-ref refs/tags/new-tag >actual &&
26 test_cmp expected actual
29 test_expect_success
'create_symref() not allowed' '
30 test_must_fail $RUN create-symref FOO refs/heads/master nothing
33 test_expect_success
'delete_refs() not allowed' '
34 test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
37 test_expect_success
'rename_refs() not allowed' '
38 test_must_fail $RUN rename-ref refs/heads/master refs/heads/new-master
41 test_expect_success
'for_each_ref(refs/heads/)' '
42 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
43 cat >expected <<-\EOF &&
47 test_cmp expected actual
50 test_expect_success
'for_each_ref() is sorted' '
51 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
52 sort actual > expected &&
53 test_cmp expected actual
56 test_expect_success
'resolve_ref(master)' '
57 SHA1=`git -C sub rev-parse master` &&
58 echo "$SHA1 refs/heads/master 0x0" >expected &&
59 $RUN resolve-ref refs/heads/master 0 >actual &&
60 test_cmp expected actual
63 test_expect_success
'verify_ref(new-master)' '
64 $RUN verify-ref refs/heads/new-master
67 test_expect_success
'for_each_reflog()' '
68 $RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
69 cat >expected <<-\EOF &&
72 refs/heads/new-master 0x0
74 test_cmp expected actual
77 test_expect_success
'for_each_reflog_ent()' '
78 $RUN for-each-reflog-ent HEAD >actual &&
79 head -n1 actual | grep first &&
80 tail -n2 actual | head -n1 | grep master.to.new
83 test_expect_success
'for_each_reflog_ent_reverse()' '
84 $RUN for-each-reflog-ent-reverse HEAD >actual &&
85 head -n1 actual | grep master.to.new &&
86 tail -n2 actual | head -n1 | grep first
89 test_expect_success
'reflog_exists(HEAD)' '
90 $RUN reflog-exists HEAD
93 test_expect_success
'delete_reflog() not allowed' '
94 test_must_fail $RUN delete-reflog HEAD
97 test_expect_success
'create-reflog() not allowed' '
98 test_must_fail $RUN create-reflog HEAD 1