submodule: convert submodule config lookup to use object_id
[alt-git.git] / t / t1405-main-ref-store.sh
blobe8115df5bad8d9ef46542cfd3c96c32da0bfa4ad
1 #!/bin/sh
3 test_description='test main ref store api'
5 . ./test-lib.sh
7 RUN="test-ref-store main"
9 test_expect_success 'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
10 test_commit one &&
11 N=`find .git/refs -type f | wc -l` &&
12 test "$N" != 0 &&
13 $RUN pack-refs 3 &&
14 N=`find .git/refs -type f | wc -l`
17 test_expect_success 'peel_ref(new-tag)' '
18 git rev-parse HEAD >expected &&
19 git tag -a -m new-tag new-tag HEAD &&
20 $RUN peel-ref refs/tags/new-tag >actual &&
21 test_cmp expected actual
24 test_expect_success 'create_symref(FOO, refs/heads/master)' '
25 $RUN create-symref FOO refs/heads/master nothing &&
26 echo refs/heads/master >expected &&
27 git symbolic-ref FOO >actual &&
28 test_cmp expected actual
31 test_expect_success 'delete_refs(FOO, refs/tags/new-tag)' '
32 git rev-parse FOO -- &&
33 git rev-parse refs/tags/new-tag -- &&
34 $RUN delete-refs 0 nothing FOO refs/tags/new-tag &&
35 test_must_fail git rev-parse FOO -- &&
36 test_must_fail git rev-parse refs/tags/new-tag --
39 test_expect_success 'rename_refs(master, new-master)' '
40 git rev-parse master >expected &&
41 $RUN rename-ref refs/heads/master refs/heads/new-master &&
42 git rev-parse new-master >actual &&
43 test_cmp expected actual &&
44 test_commit recreate-master
47 test_expect_success 'for_each_ref(refs/heads/)' '
48 $RUN for-each-ref refs/heads/ | cut -c 42- >actual &&
49 cat >expected <<-\EOF &&
50 master 0x0
51 new-master 0x0
52 EOF
53 test_cmp expected actual
56 test_expect_success 'for_each_ref() is sorted' '
57 $RUN for-each-ref refs/heads/ | cut -c 42- >actual &&
58 sort actual > expected &&
59 test_cmp expected actual
62 test_expect_success 'resolve_ref(new-master)' '
63 SHA1=`git rev-parse new-master` &&
64 echo "$SHA1 refs/heads/new-master 0x0" >expected &&
65 $RUN resolve-ref refs/heads/new-master 0 >actual &&
66 test_cmp expected actual
69 test_expect_success 'verify_ref(new-master)' '
70 $RUN verify-ref refs/heads/new-master
73 test_expect_success 'for_each_reflog()' '
74 $RUN for-each-reflog | sort | cut -c 42- >actual &&
75 cat >expected <<-\EOF &&
76 HEAD 0x1
77 refs/heads/master 0x0
78 refs/heads/new-master 0x0
79 EOF
80 test_cmp expected actual
83 test_expect_success 'for_each_reflog_ent()' '
84 $RUN for-each-reflog-ent HEAD >actual &&
85 head -n1 actual | grep one &&
86 tail -n2 actual | head -n1 | grep recreate-master
89 test_expect_success 'for_each_reflog_ent_reverse()' '
90 $RUN for-each-reflog-ent-reverse HEAD >actual &&
91 head -n1 actual | grep recreate-master &&
92 tail -n2 actual | head -n1 | grep one
95 test_expect_success 'reflog_exists(HEAD)' '
96 $RUN reflog-exists HEAD
99 test_expect_success 'delete_reflog(HEAD)' '
100 $RUN delete-reflog HEAD &&
101 ! test -f .git/logs/HEAD
104 test_expect_success 'create-reflog(HEAD)' '
105 $RUN create-reflog HEAD 1 &&
106 test -f .git/logs/HEAD
109 test_expect_success 'delete_ref(refs/heads/foo)' '
110 git checkout -b foo &&
111 FOO_SHA1=`git rev-parse foo` &&
112 git checkout --detach &&
113 test_commit bar-commit &&
114 git checkout -b bar &&
115 BAR_SHA1=`git rev-parse bar` &&
116 $RUN update-ref updating refs/heads/foo $BAR_SHA1 $FOO_SHA1 0 &&
117 echo $BAR_SHA1 >expected &&
118 git rev-parse refs/heads/foo >actual &&
119 test_cmp expected actual
122 test_expect_success 'delete_ref(refs/heads/foo)' '
123 SHA1=`git rev-parse foo` &&
124 git checkout --detach &&
125 $RUN delete-ref msg refs/heads/foo $SHA1 0 &&
126 test_must_fail git rev-parse refs/heads/foo --
129 test_done