]>
Commit | Line | Data |
---|---|---|
03a8eddf JK |
1 | #!/bin/sh |
2 | ||
3 | test_description='tests for the peel_ref optimization of packed-refs' | |
d6c6b108 | 4 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
334afbc7 JS |
5 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
6 | ||
288a4806 | 7 | TEST_PASSES_SANITIZE_LEAK=true |
03a8eddf JK |
8 | . ./test-lib.sh |
9 | ||
10 | test_expect_success 'create annotated tag in refs/tags' ' | |
11 | test_commit base && | |
12 | git tag -m annotated foo | |
13 | ' | |
14 | ||
15 | test_expect_success 'create annotated tag outside of refs/tags' ' | |
16 | git update-ref refs/outside/foo refs/tags/foo | |
17 | ' | |
18 | ||
19 | # This matches show-ref's output | |
20 | print_ref() { | |
21 | echo "$(git rev-parse "$1") $1" | |
22 | } | |
23 | ||
24 | test_expect_success 'set up expected show-ref output' ' | |
25 | { | |
d6c6b108 | 26 | print_ref "refs/heads/main" && |
03a8eddf JK |
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 | |
33 | ' | |
34 | ||
35 | test_expect_success 'refs are peeled outside of refs/tags (loose)' ' | |
36 | git show-ref -d >actual && | |
37 | test_cmp expect actual | |
38 | ' | |
39 | ||
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 | |
44 | ' | |
45 | ||
c29c46fa MH |
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. | |
52 | { | |
53 | echo "# pack-refs with: peeled " && | |
d6c6b108 | 54 | print_ref "refs/heads/main" && |
c29c46fa MH |
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 | |
61 | ' | |
62 | ||
63 | test_expect_success 'refs are peeled outside of refs/tags (old packed)' ' | |
64 | git show-ref -d >actual && | |
65 | test_cmp expect actual | |
66 | ' | |
67 | ||
694b7a19 | 68 | test_expect_success 'peeled refs survive deletion of packed ref' ' |
c995de61 MH |
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 | |
75 | ' | |
76 | ||
03a8eddf | 77 | test_done |