]> git.ipfire.org Git - thirdparty/git.git/blob - t/t1406-submodule-ref-store.sh
The third batch
[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=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
10
11 RUN="test-tool ref-store submodule:sub"
12
13 test_expect_success 'setup' '
14 git init sub &&
15 (
16 cd sub &&
17 test_commit first &&
18 git checkout -b new-main &&
19 git tag -a -m new-tag new-tag HEAD
20 )
21 '
22
23 test_expect_success 'pack_refs() not allowed' '
24 test_must_fail $RUN pack-refs 3
25 '
26
27 test_expect_success 'create_symref() not allowed' '
28 test_must_fail $RUN create-symref FOO refs/heads/main nothing
29 '
30
31 test_expect_success 'delete_refs() not allowed' '
32 test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
33 '
34
35 test_expect_success 'rename_refs() not allowed' '
36 test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main
37 '
38
39 test_expect_success 'for_each_ref(refs/heads/)' '
40 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
41 cat >expected <<-\EOF &&
42 main 0x0
43 new-main 0x0
44 EOF
45 test_cmp expected actual
46 '
47
48 test_expect_success 'for_each_ref() is sorted' '
49 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
50 sort actual > expected &&
51 test_cmp expected actual
52 '
53
54 test_expect_success 'resolve_ref(main)' '
55 SHA1=`git -C sub rev-parse main` &&
56 echo "$SHA1 refs/heads/main 0x0" >expected &&
57 $RUN resolve-ref refs/heads/main 0 >actual &&
58 test_cmp expected actual
59 '
60
61 test_expect_success 'verify_ref(new-main)' '
62 $RUN verify-ref refs/heads/new-main
63 '
64
65 test_expect_success 'for_each_reflog()' '
66 $RUN for-each-reflog >actual &&
67 cat >expected <<-\EOF &&
68 HEAD
69 refs/heads/main
70 refs/heads/new-main
71 EOF
72 test_cmp expected actual
73 '
74
75 test_expect_success 'for_each_reflog_ent()' '
76 $RUN for-each-reflog-ent HEAD >actual &&
77 head -n1 actual | grep first &&
78 tail -n1 actual | grep main.to.new
79 '
80
81 test_expect_success 'for_each_reflog_ent_reverse()' '
82 $RUN for-each-reflog-ent-reverse HEAD >actual &&
83 head -n1 actual | grep main.to.new &&
84 tail -n1 actual | grep first
85 '
86
87 test_expect_success 'reflog_exists(HEAD)' '
88 $RUN reflog-exists HEAD
89 '
90
91 test_expect_success 'delete_reflog() not allowed' '
92 test_must_fail $RUN delete-reflog HEAD
93 '
94
95 test_expect_success 'create-reflog() not allowed' '
96 test_must_fail $RUN create-reflog HEAD
97 '
98
99 test_done