]> git.ipfire.org Git - thirdparty/git.git/blob - t/t1406-submodule-ref-store.sh
path.c: don't call the match function without value in trie_find()
[thirdparty/git.git] / t / t1406-submodule-ref-store.sh
1 #!/bin/sh
2
3 test_description='test submodule ref store api'
4
5 . ./test-lib.sh
6
7 RUN="test-tool ref-store submodule:sub"
8
9 test_expect_success 'setup' '
10 git init sub &&
11 (
12 cd sub &&
13 test_commit first &&
14 git checkout -b new-master
15 )
16 '
17
18 test_expect_success 'pack_refs() not allowed' '
19 test_must_fail $RUN pack-refs 3
20 '
21
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
27 '
28
29 test_expect_success 'create_symref() not allowed' '
30 test_must_fail $RUN create-symref FOO refs/heads/master nothing
31 '
32
33 test_expect_success 'delete_refs() not allowed' '
34 test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
35 '
36
37 test_expect_success 'rename_refs() not allowed' '
38 test_must_fail $RUN rename-ref refs/heads/master refs/heads/new-master
39 '
40
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 &&
44 master 0x0
45 new-master 0x0
46 EOF
47 test_cmp expected actual
48 '
49
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
54 '
55
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
61 '
62
63 test_expect_success 'verify_ref(new-master)' '
64 $RUN verify-ref refs/heads/new-master
65 '
66
67 test_expect_success 'for_each_reflog()' '
68 $RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
69 cat >expected <<-\EOF &&
70 HEAD 0x1
71 refs/heads/master 0x0
72 refs/heads/new-master 0x0
73 EOF
74 test_cmp expected actual
75 '
76
77 test_expect_success 'for_each_reflog_ent()' '
78 $RUN for-each-reflog-ent HEAD >actual && cat actual &&
79 head -n1 actual | grep first &&
80 tail -n2 actual | head -n1 | grep master.to.new
81 '
82
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
87 '
88
89 test_expect_success 'reflog_exists(HEAD)' '
90 $RUN reflog-exists HEAD
91 '
92
93 test_expect_success 'delete_reflog() not allowed' '
94 test_must_fail $RUN delete-reflog HEAD
95 '
96
97 test_expect_success 'create-reflog() not allowed' '
98 test_must_fail $RUN create-reflog HEAD 1
99 '
100
101 test_done