(command.CommandList children: [ (command.ShAssignment pairs: [ (assign_pair lhs: (sh_lhs_expr.Name name:test_description) op: assign_op.Equal rhs: {(SQ <'tests for the peel_ref optimization of packed-refs'>)} spids: [4] ) ] ) (C {<.>} {<'./test-lib.sh'>}) (C {<test_expect_success>} {(SQ <'create annotated tag in refs/tags'>)} {(SQ <'\n'> <'\ttest_commit base &&\n'> <'\tgit tag -m annotated foo\n'>)} ) (C {<test_expect_success>} {(SQ <'create annotated tag outside of refs/tags'>)} {(SQ <'\n'> <'\tgit update-ref refs/outside/foo refs/tags/foo\n'>)} ) (command.ShFunction name: print_ref body: (BraceGroup children: [ (C {<echo>} { (DQ (command_sub left_token: <Id.Left_DollarParen '$('> child: (C {<git>} {<rev-parse>} {(DQ ($ Id.VSub_Number '$1'))}) ) <' '> ($ Id.VSub_Number '$1') ) } ) ] ) ) (C {<test_expect_success>} {(SQ <'set up expected show-ref output'>)} { (SQ <'\n'> <'\t{\n'> <'\t\tprint_ref "refs/heads/master" &&\n'> <'\t\tprint_ref "refs/outside/foo" &&\n'> <'\t\tprint_ref "refs/outside/foo^{}" &&\n'> <'\t\tprint_ref "refs/tags/base" &&\n'> <'\t\tprint_ref "refs/tags/foo" &&\n'> <'\t\tprint_ref "refs/tags/foo^{}"\n'> <'\t} >expect\n'> ) } ) (C {<test_expect_success>} {(SQ <'refs are peeled outside of refs/tags (loose)'>)} {(SQ <'\n'> <'\tgit show-ref -d >actual &&\n'> <'\ttest_cmp expect actual\n'>)} ) (C {<test_expect_success>} {(SQ <'refs are peeled outside of refs/tags (packed)'>)} { (SQ <'\n'> <'\tgit pack-refs --all &&\n'> <'\tgit show-ref -d >actual &&\n'> <'\ttest_cmp expect actual\n'> ) } ) (C {<test_expect_success>} {(SQ <'create old-style pack-refs without fully-peeled'>)} { (SQ <'\n'> <'\t# Git no longer writes without fully-peeled, so we just write our own\n'> <'\t# from scratch; we could also munge the existing file to remove the\n'> <'\t# fully-peeled bits, but that seems even more prone to failure,\n'> <'\t# especially if the format ever changes again. At least this way we\n'> <'\t# know we are emulating exactly what an older git would have written.\n'> <'\t{\n'> <'\t\techo "# pack-refs with: peeled " &&\n'> <'\t\tprint_ref "refs/heads/master" &&\n'> <'\t\tprint_ref "refs/outside/foo" &&\n'> <'\t\tprint_ref "refs/tags/base" &&\n'> <'\t\tprint_ref "refs/tags/foo" &&\n'> <'\t\techo "^$(git rev-parse "refs/tags/foo^{}")"\n'> <'\t} >tmp &&\n'> <'\tmv tmp .git/packed-refs\n'> ) } ) (C {<test_expect_success>} {(SQ <'refs are peeled outside of refs/tags (old packed)'>)} {(SQ <'\n'> <'\tgit show-ref -d >actual &&\n'> <'\ttest_cmp expect actual\n'>)} ) (C {<test_expect_success>} {(SQ <'peeled refs survive deletion of packed ref'>)} { (SQ <'\n'> <'\tgit pack-refs --all &&\n'> <'\tcp .git/packed-refs fully-peeled &&\n'> <'\tgit branch yadda &&\n'> <'\tgit pack-refs --all &&\n'> <'\tgit branch -d yadda &&\n'> <'\ttest_cmp fully-peeled .git/packed-refs\n'> ) } ) (C {<test_done>}) ] )