1#!/bin/sh
23
test_description='tests for the peel_ref optimization of packed-refs'
4. ./test-lib.sh
56
test_expect_success 'create annotated tag in refs/tags' '
7test_commit base &&
8git tag -m annotated foo
9'
1011
test_expect_success 'create annotated tag outside of refs/tags' '
12git update-ref refs/outside/foo refs/tags/foo
13'
1415
# This matches show-ref's output
16print_ref() {
17echo "$(git rev-parse "$1") $1"
18}
1920
test_expect_success 'set up expected show-ref output' '
21{
22print_ref "refs/heads/master" &&
23print_ref "refs/outside/foo" &&
24print_ref "refs/outside/foo^{}" &&
25print_ref "refs/tags/base" &&
26print_ref "refs/tags/foo" &&
27print_ref "refs/tags/foo^{}"
28} >expect
29'
3031
test_expect_success 'refs are peeled outside of refs/tags (loose)' '
32git show-ref -d >actual &&
33test_cmp expect actual
34'
3536
test_expect_success 'refs are peeled outside of refs/tags (packed)' '
37git pack-refs --all &&
38git show-ref -d >actual &&
39test_cmp expect actual
40'
4142
test_expect_success 'create old-style pack-refs without fully-peeled' '
43# Git no longer writes without fully-peeled, so we just write our own
44# from scratch; we could also munge the existing file to remove the
45# fully-peeled bits, but that seems even more prone to failure,
46# especially if the format ever changes again. At least this way we
47# know we are emulating exactly what an older git would have written.
48{
49echo "# pack-refs with: peeled " &&
50print_ref "refs/heads/master" &&
51print_ref "refs/outside/foo" &&
52print_ref "refs/tags/base" &&
53print_ref "refs/tags/foo" &&
54echo "^$(git rev-parse "refs/tags/foo^{}")"
55} >tmp &&
56mv tmp .git/packed-refs
57'
5859
test_expect_success 'refs are peeled outside of refs/tags (old packed)' '
60git show-ref -d >actual &&
61test_cmp expect actual
62'
6364
test_done