]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3211-peel-ref.sh
help: make sure local html page exists before calling external processes
[thirdparty/git.git] / t / t3211-peel-ref.sh
CommitLineData
03a8eddf
JK
1#!/bin/sh
2
3test_description='tests for the peel_ref optimization of packed-refs'
d6c6b108 4GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
5export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
6
03a8eddf
JK
7. ./test-lib.sh
8
9test_expect_success 'create annotated tag in refs/tags' '
10 test_commit base &&
11 git tag -m annotated foo
12'
13
14test_expect_success 'create annotated tag outside of refs/tags' '
15 git update-ref refs/outside/foo refs/tags/foo
16'
17
18# This matches show-ref's output
19print_ref() {
20 echo "$(git rev-parse "$1") $1"
21}
22
23test_expect_success 'set up expected show-ref output' '
24 {
d6c6b108 25 print_ref "refs/heads/main" &&
03a8eddf
JK
26 print_ref "refs/outside/foo" &&
27 print_ref "refs/outside/foo^{}" &&
28 print_ref "refs/tags/base" &&
29 print_ref "refs/tags/foo" &&
30 print_ref "refs/tags/foo^{}"
31 } >expect
32'
33
34test_expect_success 'refs are peeled outside of refs/tags (loose)' '
35 git show-ref -d >actual &&
36 test_cmp expect actual
37'
38
39test_expect_success 'refs are peeled outside of refs/tags (packed)' '
40 git pack-refs --all &&
41 git show-ref -d >actual &&
42 test_cmp expect actual
43'
44
c29c46fa
MH
45test_expect_success 'create old-style pack-refs without fully-peeled' '
46 # Git no longer writes without fully-peeled, so we just write our own
47 # from scratch; we could also munge the existing file to remove the
48 # fully-peeled bits, but that seems even more prone to failure,
49 # especially if the format ever changes again. At least this way we
50 # know we are emulating exactly what an older git would have written.
51 {
52 echo "# pack-refs with: peeled " &&
d6c6b108 53 print_ref "refs/heads/main" &&
c29c46fa
MH
54 print_ref "refs/outside/foo" &&
55 print_ref "refs/tags/base" &&
56 print_ref "refs/tags/foo" &&
57 echo "^$(git rev-parse "refs/tags/foo^{}")"
58 } >tmp &&
59 mv tmp .git/packed-refs
60'
61
62test_expect_success 'refs are peeled outside of refs/tags (old packed)' '
63 git show-ref -d >actual &&
64 test_cmp expect actual
65'
66
694b7a19 67test_expect_success 'peeled refs survive deletion of packed ref' '
c995de61
MH
68 git pack-refs --all &&
69 cp .git/packed-refs fully-peeled &&
70 git branch yadda &&
71 git pack-refs --all &&
72 git branch -d yadda &&
73 test_cmp fully-peeled .git/packed-refs
74'
75
03a8eddf 76test_done