interplane.Get Omega
Read in your language

git

[Ported from github.com/git/git] Sync with Git 2.56.1

Brought by drakestapleton

branch master Branches Tags History

git / t / t1406-submodule-ref-store.sh

98 lines · 2237 bytes Raw Blame History
1#!/bin/sh
2
3test_description='test submodule ref store api'
4
5GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7
8. ./test-lib.sh
9
10RUN="test-tool ref-store submodule:sub"
11
12test_expect_success 'setup' '
13 git init sub &&
14 (
15 cd sub &&
16 test_commit first &&
17 git checkout -b new-main &&
18 git tag -a -m new-tag new-tag HEAD
19 )
20'
21
22test_expect_success 'pack_refs() not allowed' '
23 test_must_fail $RUN pack-refs 3
24'
25
26test_expect_success 'create_symref() not allowed' '
27 test_must_fail $RUN create-symref FOO refs/heads/main nothing
28'
29
30test_expect_success 'delete_refs() not allowed' '
31 test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
32'
33
34test_expect_success 'rename_refs() not allowed' '
35 test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main
36'
37
38test_expect_success 'for_each_ref(refs/heads/)' '
39 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
40 cat >expected <<-\EOF &&
41 main 0x0
42 new-main 0x0
43 EOF
44 test_cmp expected actual
45'
46
47test_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
51'
52
53test_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
58'
59
60test_expect_success 'verify_ref(new-main)' '
61 $RUN verify-ref refs/heads/new-main
62'
63
64test_expect_success 'for_each_reflog()' '
65 $RUN for-each-reflog >actual &&
66 cat >expected <<-\EOF &&
67 HEAD
68 refs/heads/main
69 refs/heads/new-main
70 EOF
71 test_cmp expected actual
72'
73
74test_expect_success 'for_each_reflog_ent()' '
75 $RUN for-each-reflog-ent HEAD >actual &&
76 head -n1 actual | grep first &&
77 tail -n1 actual | grep main.to.new
78'
79
80test_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 -n1 actual | grep first
84'
85
86test_expect_success 'reflog_exists(HEAD)' '
87 $RUN reflog-exists HEAD
88'
89
90test_expect_success 'delete_reflog() not allowed' '
91 test_must_fail $RUN delete-reflog HEAD
92'
93
94test_expect_success 'create-reflog() not allowed' '
95 test_must_fail $RUN create-reflog HEAD
96'
97
98test_done