reftable/stack: expose option to disable auto-compaction
[git.git] / t / t3211-peel-ref.sh
blob9cbc34fc5838b4d4a886135352e92d613ca8146a
1 #!/bin/sh
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
8 . ./test-lib.sh
10 test_expect_success 'create annotated tag in refs/tags' '
11 test_commit base &&
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
20 print_ref() {
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^{}"
32 } >expect
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^{}")"
59 } >tmp &&
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 &&
71 git branch yadda &&
72 git pack-refs --all &&
73 git branch -d yadda &&
74 test_cmp fully-peeled .git/packed-refs
77 test_done