pack-objects: simplify --filter handling
[git/debian.git] / t / t1406-submodule-ref-store.sh
blobe6a7f7334b6a96e4aa310532c8dc7d6c727fdd16
1 #!/bin/sh
3 test_description='test submodule ref store api'
5 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
6 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
8 TEST_PASSES_SANITIZE_LEAK=true
9 . ./test-lib.sh
11 RUN="test-tool ref-store submodule:sub"
13 test_expect_success 'setup' '
14 git init sub &&
16 cd sub &&
17 test_commit first &&
18 git checkout -b new-main &&
19 git tag -a -m new-tag new-tag HEAD
23 test_expect_success 'pack_refs() not allowed' '
24 test_must_fail $RUN pack-refs 3
27 test_expect_success 'create_symref() not allowed' '
28 test_must_fail $RUN create-symref FOO refs/heads/main nothing
31 test_expect_success 'delete_refs() not allowed' '
32 test_must_fail $RUN delete-refs 0 nothing FOO refs/tags/new-tag
35 test_expect_success 'rename_refs() not allowed' '
36 test_must_fail $RUN rename-ref refs/heads/main refs/heads/new-main
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
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
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
61 test_expect_success 'verify_ref(new-main)' '
62 $RUN verify-ref refs/heads/new-main
65 test_expect_success 'for_each_reflog()' '
66 $RUN for-each-reflog | sort | cut -d" " -f 2- >actual &&
67 cat >expected <<-\EOF &&
68 HEAD 0x1
69 refs/heads/main 0x0
70 refs/heads/new-main 0x0
71 EOF
72 test_cmp expected actual
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
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
87 test_expect_success 'reflog_exists(HEAD)' '
88 $RUN reflog-exists HEAD
91 test_expect_success 'delete_reflog() not allowed' '
92 test_must_fail $RUN delete-reflog HEAD
95 test_expect_success 'create-reflog() not allowed' '
96 test_must_fail $RUN create-reflog HEAD
99 test_done