3 test_description
='test main ref store api'
7 RUN
="test-tool ref-store main"
9 test_expect_success
'pack_refs(PACK_REFS_ALL | PACK_REFS_PRUNE)' '
11 N=`find .git/refs -type f | wc -l` &&
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 m=$(git rev-parse master) &&
36 $RUN delete-refs $REF_NO_DEREF nothing FOO refs/tags/new-tag &&
37 test_must_fail git rev-parse --symbolic-full-name FOO &&
38 test_must_fail git rev-parse FOO -- &&
39 test_must_fail git rev-parse refs/tags/new-tag --
42 test_expect_success
'rename_refs(master, new-master)' '
43 git rev-parse master >expected &&
44 $RUN rename-ref refs/heads/master refs/heads/new-master &&
45 git rev-parse new-master >actual &&
46 test_cmp expected actual &&
47 test_commit recreate-master
50 test_expect_success
'for_each_ref(refs/heads/)' '
51 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
52 cat >expected <<-\EOF &&
56 test_cmp expected actual
59 test_expect_success
'for_each_ref() is sorted' '
60 $RUN for-each-ref refs/heads/ | cut -d" " -f 2- >actual &&
61 sort actual > expected &&
62 test_cmp expected actual
65 test_expect_success
'resolve_ref(new-master)' '
66 SHA1=`git rev-parse new-master` &&
67 echo "$SHA1 refs/heads/new-master 0x0" >expected &&
68 $RUN resolve-ref refs/heads/new-master 0 >actual &&
69 test_cmp expected actual
72 test_expect_success
'verify_ref(new-master)' '
73 $RUN verify-ref refs/heads/new-master
76 test_expect_success
'for_each_reflog()' '
77 $RUN for-each-reflog | sort -k2 | cut -d" " -f 2- >actual &&
78 cat >expected <<-\EOF &&
81 refs/heads/new-master 0x0
83 test_cmp expected actual
86 test_expect_success
'for_each_reflog_ent()' '
87 $RUN for-each-reflog-ent HEAD >actual &&
88 head -n1 actual | grep one &&
89 tail -n2 actual | head -n1 | grep recreate-master
92 test_expect_success
'for_each_reflog_ent_reverse()' '
93 $RUN for-each-reflog-ent-reverse HEAD >actual &&
94 head -n1 actual | grep recreate-master &&
95 tail -n2 actual | head -n1 | grep one
98 test_expect_success
'reflog_exists(HEAD)' '
99 $RUN reflog-exists HEAD
102 test_expect_success
'delete_reflog(HEAD)' '
103 $RUN delete-reflog HEAD &&
104 ! test -f .git/logs/HEAD
107 test_expect_success
'create-reflog(HEAD)' '
108 $RUN create-reflog HEAD 1 &&
109 test -f .git/logs/HEAD
112 test_expect_success
'delete_ref(refs/heads/foo)' '
113 git checkout -b foo &&
114 FOO_SHA1=`git rev-parse foo` &&
115 git checkout --detach &&
116 test_commit bar-commit &&
117 git checkout -b bar &&
118 BAR_SHA1=`git rev-parse bar` &&
119 $RUN update-ref updating refs/heads/foo $BAR_SHA1 $FOO_SHA1 0 &&
120 echo $BAR_SHA1 >expected &&
121 git rev-parse refs/heads/foo >actual &&
122 test_cmp expected actual
125 test_expect_success
'delete_ref(refs/heads/foo)' '
126 SHA1=`git rev-parse foo` &&
127 git checkout --detach &&
128 $RUN delete-ref msg refs/heads/foo $SHA1 0 &&
129 test_must_fail git rev-parse refs/heads/foo --