1#!/bin/sh23test_description='tests for the peel_ref optimization of packed-refs'4. ./test-lib.sh56test_expect_success 'create annotated tag in refs/tags' '7test_commit base &&8git tag -m annotated foo9'1011test_expect_success 'create annotated tag outside of refs/tags' '12git update-ref refs/outside/foo refs/tags/foo13'1415# This matches show-ref's output16print_ref() {17echo "$(git rev-parse "$1") $1"18}1920test_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} >expect29'3031test_expect_success 'refs are peeled outside of refs/tags (loose)' '32git show-ref -d >actual &&33test_cmp expect actual34'3536test_expect_success 'refs are peeled outside of refs/tags (packed)' '37git pack-refs --all &&38git show-ref -d >actual &&39test_cmp expect actual40'4142test_expect_success 'create old-style pack-refs without fully-peeled' '43# Git no longer writes without fully-peeled, so we just write our own44# from scratch; we could also munge the existing file to remove the45# fully-peeled bits, but that seems even more prone to failure,46# especially if the format ever changes again. At least this way we47# 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-refs57'5859test_expect_success 'refs are peeled outside of refs/tags (old packed)' '60git show-ref -d >actual &&61test_cmp expect actual62'6364test_done