]> git.ipfire.org Git - thirdparty/git.git/blob - t/t1406-submodule-ref-store.sh
tests: mark tests relying on the current default for `init.defaultBranch`
[thirdparty/git.git] / t / t1406-submodule-ref-store.sh
1 #!/bin/sh
2
3 test_description='test submodule ref store api'
4
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=master
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 . ./test-lib.sh
9
10 RUN="test-tool ref-store submodule:sub"
11
12 test_expect_success 'setup' '
13 git init sub &&
14 (
15 cd sub &&
16 test_commit first &&
17 git checkout -b new-master
18 )
19 '
20
21 test_expect_success 'pack_refs() not allowed' '
22 test_must_fail $RUN pack-refs 3
23 '
24
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
30 '
31
32 test_expect_success 'create_symref() not allowed' '
33 test_must_fail $RUN create-symref FOO refs/heads/master nothing
34 '
35
36 test_expect_success 'delete_refs() not allowed' '
37 test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
38 '
39
40 test_expect_success 'rename_refs() not allowed' '
41 test_must_fail $RUN rename-ref refs/heads/master refs/heads/new-master
42 '
43
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 &&
47 master 0x0
48 new-master 0x0
49 EOF
50 test_cmp expected actual
51 '
52
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
57 '
58
59 test_expect_success 'resolve_ref(master)' '
60 SHA1=`git -C sub rev-parse master` &&
61 echo "$SHA1 refs/heads/master 0x0" >expected &&
62 $RUN resolve-ref refs/heads/master 0 >actual &&
63 test_cmp expected actual
64 '
65
66 test_expect_success 'verify_ref(new-master)' '
67 $RUN verify-ref refs/heads/new-master
68 '
69
70 test_expect_success 'for_each_reflog()' '
71 $RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
72 cat >expected <<-\EOF &&
73 HEAD 0x1
74 refs/heads/master 0x0
75 refs/heads/new-master 0x0
76 EOF
77 test_cmp expected actual
78 '
79
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 master.to.new
84 '
85
86 test_expect_success 'for_each_reflog_ent_reverse()' '
87 $RUN for-each-reflog-ent-reverse HEAD >actual &&
88 head -n1 actual | grep master.to.new &&
89 tail -n2 actual | head -n1 | grep first
90 '
91
92 test_expect_success 'reflog_exists(HEAD)' '
93 $RUN reflog-exists HEAD
94 '
95
96 test_expect_success 'delete_reflog() not allowed' '
97 test_must_fail $RUN delete-reflog HEAD
98 '
99
100 test_expect_success 'create-reflog() not allowed' '
101 test_must_fail $RUN create-reflog HEAD 1
102 '
103
104 test_done