3 test_description
='tests for the peel_ref optimization of packed-refs'
4 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
5 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
7 TEST_PASSES_SANITIZE_LEAK
=true
10 test_expect_success
'create annotated tag in refs/tags' '
12 git tag -m annotated foo
15 test_expect_success
'create annotated tag outside of refs/tags' '
16 git update-ref refs/outside/foo refs/tags/foo
19 # This matches show-ref's output
21 echo "$(git rev-parse "$1") $1"
24 test_expect_success
'set up expected show-ref output' '
26 print_ref "refs/heads/main" &&
27 print_ref "refs/outside/foo" &&
28 print_ref "refs/outside/foo^{}" &&
29 print_ref "refs/tags/base" &&
30 print_ref "refs/tags/foo" &&
31 print_ref "refs/tags/foo^{}"
35 test_expect_success
'refs are peeled outside of refs/tags (loose)' '
36 git show-ref -d >actual &&
37 test_cmp expect actual
40 test_expect_success
'refs are peeled outside of refs/tags (packed)' '
41 git pack-refs --all &&
42 git show-ref -d >actual &&
43 test_cmp expect actual
46 test_expect_success
'create old-style pack-refs without fully-peeled' '
47 # Git no longer writes without fully-peeled, so we just write our own
48 # from scratch; we could also munge the existing file to remove the
49 # fully-peeled bits, but that seems even more prone to failure,
50 # especially if the format ever changes again. At least this way we
51 # know we are emulating exactly what an older git would have written.
53 echo "# pack-refs with: peeled " &&
54 print_ref "refs/heads/main" &&
55 print_ref "refs/outside/foo" &&
56 print_ref "refs/tags/base" &&
57 print_ref "refs/tags/foo" &&
58 echo "^$(git rev-parse "refs/tags/foo^{}")"
60 mv tmp .git/packed-refs
63 test_expect_success
'refs are peeled outside of refs/tags (old packed)' '
64 git show-ref -d >actual &&
65 test_cmp expect actual
68 test_expect_success
'peeled refs survive deletion of packed ref' '
69 git pack-refs --all &&
70 cp .git/packed-refs fully-peeled &&
72 git pack-refs --all &&
73 git branch -d yadda &&
74 test_cmp fully-peeled .git/packed-refs