git-apply: try threeway first when "--3way" is used
[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-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-main &&
18                 git tag -a -m new-tag new-tag HEAD
19         )
20 '
21
22 test_expect_success 'pack_refs() not allowed' '
23         test_must_fail $RUN pack-refs 3
24 '
25
26 test_expect_success 'create_symref() not allowed' '
27         test_must_fail $RUN create-symref FOO refs/heads/main nothing
28 '
29
30 test_expect_success 'delete_refs() not allowed' '
31         test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
32 '
33
34 test_expect_success 'rename_refs() not allowed' '
35         test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main
36 '
37
38 test_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
47 test_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
53 test_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
60 test_expect_success 'verify_ref(new-main)' '
61         $RUN verify-ref refs/heads/new-main
62 '
63
64 test_expect_success 'for_each_reflog()' '
65         $RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
66         cat >expected <<-\EOF &&
67         HEAD 0x1
68         refs/heads/main 0x0
69         refs/heads/new-main 0x0
70         EOF
71         test_cmp expected actual
72 '
73
74 test_expect_success 'for_each_reflog_ent()' '
75         $RUN for-each-reflog-ent HEAD >actual &&
76         head -n1 actual | grep first &&
77         tail -n2 actual | head -n1 | grep main.to.new
78 '
79
80 test_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 -n2 actual | head -n1 | grep first
84 '
85
86 test_expect_success 'reflog_exists(HEAD)' '
87         $RUN reflog-exists HEAD
88 '
89
90 test_expect_success 'delete_reflog() not allowed' '
91         test_must_fail $RUN delete-reflog HEAD
92 '
93
94 test_expect_success 'create-reflog() not allowed' '
95         test_must_fail $RUN create-reflog HEAD 1
96 '
97
98 test_done