(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'test for-each-refs usage of ref-filter APIs'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<./test-lib.sh>})
    (C {<.>} {(DQ ($ Id.VSub_DollarName '$TEST_DIRECTORY')) </lib-gpg.sh>})
    (C {<test_expect_success>} {(SQ <'setup some history and refs'>)} 
      {
        (SQ <'\n'> <'\ttest_commit one &&\n'> <'\ttest_commit two &&\n'> <'\ttest_commit three &&\n'> 
          <'\tgit checkout -b side &&\n'> <'\ttest_commit four &&\n'> <'\tgit tag -m "An annotated tag" annotated-tag &&\n'> 
          <'\tgit tag -m "Annonated doubly" doubly-annotated-tag annotated-tag &&\n'> <'\n'> <'\t# Note that these "signed" tags might not actually be signed.\n'> 
          <'\t# Tests which care about the distinction should be marked\n'> <'\t# with the GPG prereq.\n'> <'\tif test_have_prereq GPG\n'> <'\tthen\n'> <'\t\tsign=-s\n'> 
          <'\telse\n'> <'\t\tsign=\n'> <'\tfi &&\n'> <'\tgit tag $sign -m "A signed tag" signed-tag &&\n'> 
          <'\tgit tag $sign -m "Signed doubly" doubly-signed-tag signed-tag &&\n'> <'\n'> <'\tgit checkout master &&\n'> <'\tgit update-ref refs/odd/spot master\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'filtering with --points-at'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\trefs/heads/master\n'> <'\trefs/odd/spot\n'> 
          <'\trefs/tags/three\n'> <'\tEOF\n'> <'\tgit for-each-ref --format="%(refname)" --points-at=master >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'check signed tags with --points-at'>)} 
      {
        (SQ <'\n'> <'\tsed -e "s/Z$//" >expect <<-\\EOF &&\n'> <'\trefs/heads/side Z\n'> 
          <'\trefs/tags/annotated-tag four\n'> <'\trefs/tags/four Z\n'> <'\trefs/tags/signed-tag four\n'> <'\tEOF\n'> 
          <'\tgit for-each-ref --format="%(refname) %(*subject)" --points-at=side >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'filtering with --merged'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\trefs/heads/master\n'> <'\trefs/odd/spot\n'> 
          <'\trefs/tags/one\n'> <'\trefs/tags/three\n'> <'\trefs/tags/two\n'> <'\tEOF\n'> 
          <'\tgit for-each-ref --format="%(refname)" --merged=master >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'filtering with --no-merged'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\trefs/heads/side\n'> 
          <'\trefs/tags/annotated-tag\n'> <'\trefs/tags/doubly-annotated-tag\n'> <'\trefs/tags/doubly-signed-tag\n'> <'\trefs/tags/four\n'> 
          <'\trefs/tags/signed-tag\n'> <'\tEOF\n'> <'\tgit for-each-ref --format="%(refname)" --no-merged=master >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'filtering with --contains'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\trefs/heads/master\n'> <'\trefs/heads/side\n'> 
          <'\trefs/odd/spot\n'> <'\trefs/tags/annotated-tag\n'> <'\trefs/tags/doubly-annotated-tag\n'> 
          <'\trefs/tags/doubly-signed-tag\n'> <'\trefs/tags/four\n'> <'\trefs/tags/signed-tag\n'> <'\trefs/tags/three\n'> <'\trefs/tags/two\n'> 
          <'\tEOF\n'> <'\tgit for-each-ref --format="%(refname)" --contains=two >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'%(color) must fail'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git for-each-ref --format="%(color)%(refname)"\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'left alignment is default'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\trefname is refs/heads/master  |refs/heads/master\n'> <'\trefname is refs/heads/side    |refs/heads/side\n'> 
          <'\trefname is refs/odd/spot      |refs/odd/spot\n'> <'\trefname is refs/tags/annotated-tag|refs/tags/annotated-tag\n'> 
          <'\trefname is refs/tags/doubly-annotated-tag|refs/tags/doubly-annotated-tag\n'> <'\trefname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag\n'> 
          <'\trefname is refs/tags/four     |refs/tags/four\n'> <'\trefname is refs/tags/one      |refs/tags/one\n'> 
          <'\trefname is refs/tags/signed-tag|refs/tags/signed-tag\n'> <'\trefname is refs/tags/three    |refs/tags/three\n'> 
          <'\trefname is refs/tags/two      |refs/tags/two\n'> <'\tEOF\n'> 
          <
'\tgit for-each-ref --format="%(align:30)refname is %(refname)%(end)|%(refname)" >actual &&\n'
          > <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'middle alignment'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\t| refname is refs/heads/master |refs/heads/master\n'> <'\t|  refname is refs/heads/side  |refs/heads/side\n'> 
          <'\t|   refname is refs/odd/spot   |refs/odd/spot\n'> <'\t|refname is refs/tags/annotated-tag|refs/tags/annotated-tag\n'> 
          <'\t|refname is refs/tags/doubly-annotated-tag|refs/tags/doubly-annotated-tag\n'> <'\t|refname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag\n'> 
          <'\t|  refname is refs/tags/four   |refs/tags/four\n'> <'\t|   refname is refs/tags/one   |refs/tags/one\n'> 
          <'\t|refname is refs/tags/signed-tag|refs/tags/signed-tag\n'> <'\t|  refname is refs/tags/three  |refs/tags/three\n'> 
          <'\t|   refname is refs/tags/two   |refs/tags/two\n'> <'\tEOF\n'> 
          <
'\tgit for-each-ref --format="|%(align:middle,30)refname is %(refname)%(end)|%(refname)" >actual &&\n'
          > <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'right alignment'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\t|  refname is refs/heads/master|refs/heads/master\n'> <'\t|    refname is refs/heads/side|refs/heads/side\n'> 
          <'\t|      refname is refs/odd/spot|refs/odd/spot\n'> <'\t|refname is refs/tags/annotated-tag|refs/tags/annotated-tag\n'> 
          <'\t|refname is refs/tags/doubly-annotated-tag|refs/tags/doubly-annotated-tag\n'> <'\t|refname is refs/tags/doubly-signed-tag|refs/tags/doubly-signed-tag\n'> 
          <'\t|     refname is refs/tags/four|refs/tags/four\n'> <'\t|      refname is refs/tags/one|refs/tags/one\n'> 
          <'\t|refname is refs/tags/signed-tag|refs/tags/signed-tag\n'> <'\t|    refname is refs/tags/three|refs/tags/three\n'> 
          <'\t|      refname is refs/tags/two|refs/tags/two\n'> <'\tEOF\n'> 
          <
'\tgit for-each-ref --format="|%(align:30,right)refname is %(refname)%(end)|%(refname)" >actual &&\n'
          > <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir.Redir op:<Id.Redir_Great '>'> fd:-1 arg_word:{<expect>})
        (redir.HereDoc
          op: <Id.Redir_DLessDash '<<-'>
          fd: -1
          here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
          here_end_span_id: 268
          stdin_parts: [
            <'|       refname is refs/heads/master       |refs/heads/master\n'>
            <'|        refname is refs/heads/side        |refs/heads/side\n'>
            <'|         refname is refs/odd/spot         |refs/odd/spot\n'>
            <'|    refname is refs/tags/annotated-tag    |refs/tags/annotated-tag\n'>
            <'|refname is refs/tags/doubly-annotated-tag |refs/tags/doubly-annotated-tag\n'>
            <'|  refname is refs/tags/doubly-signed-tag  |refs/tags/doubly-signed-tag\n'>
            <'|        refname is refs/tags/four         |refs/tags/four\n'>
            <'|         refname is refs/tags/one         |refs/tags/one\n'>
            <'|     refname is refs/tags/signed-tag      |refs/tags/signed-tag\n'>
            <'|        refname is refs/tags/three        |refs/tags/three\n'>
            <'|         refname is refs/tags/two         |refs/tags/two\n'>
          ]
        )
      ]
    )
    (command.ShFunction
      name: test_align_permutations
      body: 
        (command.BraceGroup
          children: [
            (command.WhileUntil
              keyword: <Id.KW_While while>
              cond: [(C {<read>} {<-r>} {<option>})]
              body: 
                (command.DoGroup
                  children: [
                    (C {<test_expect_success>} {(DQ <'align:'> ($ Id.VSub_DollarName '$option'))} 
                      {
                        (SQ <'\n'> 
                          <
'\t\t\tgit for-each-ref --format="|%(align:$option)refname is %(refname)%(end)|%(refname)" >actual &&\n'
                          > <'\t\t\ttest_cmp expect actual\n'> <'\t\t'>
                        )
                      }
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.Simple
      words: [{<test_align_permutations>}]
      redirects: [
        (redir.HereDoc
          op: <Id.Redir_DLessDash '<<-'>
          fd: -1
          here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
          here_end_span_id: 323
          stdin_parts: [
            <'middle,42\n'>
            <'42,middle\n'>
            <'position=middle,42\n'>
            <'42,position=middle\n'>
            <'middle,width=42\n'>
            <'width=42,middle\n'>
            <'position=middle,width=42\n'>
            <'width=42,position=middle\n'>
          ]
        )
      ]
    )
    (command.Simple
      words: [{<test_align_permutations>}]
      redirects: [
        (redir.HereDoc
          op: <Id.Redir_DLessDash '<<-'>
          fd: -1
          here_begin: {(word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\E'>) <OF>}
          here_end_span_id: 339
          stdin_parts: [
            <'32,width=42,middle\n'>
            <'width=30,42,middle\n'>
            <'width=42,position=right,middle\n'>
            <'42,right,position=middle\n'>
          ]
        )
      ]
    )
    (C {<test_expect_success>} {(SQ <'alignment with format quote'>)} 
      {
        (DQ <'\n'> <'\tcat >expect <<-'> <Id.Lit_Other '\\'> <'EOF &&\n'> <"\t|'      '"> 
          <Id.Lit_Other '\\'> <"''master| A U Thor'"> <Id.Lit_Other '\\'> <"''      '|\n"> <"\t|'       '"> <Id.Lit_Other '\\'> 
          <"''side| A U Thor'"> <Id.Lit_Other '\\'> <"''       '|\n"> <"\t|'     '"> <Id.Lit_Other '\\'> <"''odd/spot| A U Thor'"> 
          <Id.Lit_Other '\\'> <"''     '|\n"> <"\t|'      '"> <Id.Lit_Other '\\'> <"''annotated-tag| '"> <Id.Lit_Other '\\'> 
          <"''       '|\n"> <"\t|'   '"> <Id.Lit_Other '\\'> <"''doubly-annotated-tag| '"> <Id.Lit_Other '\\'> <"''   '|\n"> 
          <"\t|'    '"> <Id.Lit_Other '\\'> <"''doubly-signed-tag| '"> <Id.Lit_Other '\\'> <"''     '|\n"> <"\t|'       '"> 
          <Id.Lit_Other '\\'> <"''four| A U Thor'"> <Id.Lit_Other '\\'> <"''       '|\n"> <"\t|'       '"> <Id.Lit_Other '\\'> 
          <"''one| A U Thor'"> <Id.Lit_Other '\\'> <"''        '|\n"> <"\t|'        '"> <Id.Lit_Other '\\'> <"''signed-tag| '"> 
          <Id.Lit_Other '\\'> <"''        '|\n"> <"\t|'      '"> <Id.Lit_Other '\\'> <"''three| A U Thor'"> <Id.Lit_Other '\\'> 
          <"''       '|\n"> <"\t|'       '"> <Id.Lit_Other '\\'> <"''two| A U Thor'"> <Id.Lit_Other '\\'> <"''        '|\n"> 
          <'\tEOF\n'> <'\tgit for-each-ref --shell --format='> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) 
          <"|%(align:30,middle)'%(refname:short)| %(authorname)'%(end)|"> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <' >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'nested alignment with quote formatting'>)} 
      {
        (DQ <'\n'> <'\tcat >expect <<-'> <Id.Lit_Other '\\'> <'EOF &&\n'> 
          <"\t|'         master               '|\n"> <"\t|'           side               '|\n"> <"\t|'       odd/spot               '|\n"> 
          <"\t|'  annotated-tag               '|\n"> <"\t|'doubly-annotated-tag          '|\n"> <"\t|'doubly-signed-tag             '|\n"> 
          <"\t|'           four               '|\n"> <"\t|'            one               '|\n"> <"\t|'     signed-tag               '|\n"> 
          <"\t|'          three               '|\n"> <"\t|'            two               '|\n"> <'\tEOF\n'> 
          <
"\tgit for-each-ref --shell --format='|%(align:30,left)%(align:15,right)%(refname:short)%(end)%(end)|' >actual &&\n"
          > <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'check `%(contents:lines=1)`'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\tmaster |three\n'> <'\tside |four\n'> 
          <'\todd/spot |three\n'> <'\tannotated-tag |An annotated tag\n'> <'\tdoubly-annotated-tag |Annonated doubly\n'> 
          <'\tdoubly-signed-tag |Signed doubly\n'> <'\tfour |four\n'> <'\tone |one\n'> <'\tsigned-tag |A signed tag\n'> <'\tthree |three\n'> 
          <'\ttwo |two\n'> <'\tEOF\n'> <'\tgit for-each-ref --format="%(refname:short) |%(contents:lines=1)" >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'check `%(contents:lines=0)`'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\tmaster |\n'> <'\tside |\n'> <'\todd/spot |\n'> 
          <'\tannotated-tag |\n'> <'\tdoubly-annotated-tag |\n'> <'\tdoubly-signed-tag |\n'> <'\tfour |\n'> <'\tone |\n'> 
          <'\tsigned-tag |\n'> <'\tthree |\n'> <'\ttwo |\n'> <'\tEOF\n'> 
          <'\tgit for-each-ref --format="%(refname:short) |%(contents:lines=0)" >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'check `%(contents:lines=99999)`'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> <'\tmaster |three\n'> <'\tside |four\n'> 
          <'\todd/spot |three\n'> <'\tannotated-tag |An annotated tag\n'> <'\tdoubly-annotated-tag |Annonated doubly\n'> 
          <'\tdoubly-signed-tag |Signed doubly\n'> <'\tfour |four\n'> <'\tone |one\n'> <'\tsigned-tag |A signed tag\n'> <'\tthree |three\n'> 
          <'\ttwo |two\n'> <'\tEOF\n'> <'\tgit for-each-ref --format="%(refname:short) |%(contents:lines=99999)" >actual &&\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'`%(contents:lines=-1)` should fail'>)} 
      {
        (SQ <'\n'> 
          <'\ttest_must_fail git for-each-ref --format="%(refname:short) |%(contents:lines=-1)"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'setup for version sort'>)} 
      {
        (SQ <'\n'> <'\ttest_commit foo1.3 &&\n'> <'\ttest_commit foo1.6 &&\n'> 
          <'\ttest_commit foo1.10\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'version sort'>)} 
      {
        (SQ <'\n'> 
          <
'\tgit for-each-ref --sort=version:refname --format="%(refname:short)" refs/tags/ | grep "foo" >actual &&\n'
          > <'\tcat >expect <<-\\EOF &&\n'> <'\tfoo1.3\n'> <'\tfoo1.6\n'> <'\tfoo1.10\n'> <'\tEOF\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'version sort (shortened)'>)} 
      {
        (SQ <'\n'> 
          <
'\tgit for-each-ref --sort=v:refname --format="%(refname:short)" refs/tags/ | grep "foo" >actual &&\n'
          > <'\tcat >expect <<-\\EOF &&\n'> <'\tfoo1.3\n'> <'\tfoo1.6\n'> <'\tfoo1.10\n'> <'\tEOF\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'reverse version sort'>)} 
      {
        (SQ <'\n'> 
          <
'\tgit for-each-ref --sort=-version:refname --format="%(refname:short)" refs/tags/ | grep "foo" >actual &&\n'
          > <'\tcat >expect <<-\\EOF &&\n'> <'\tfoo1.10\n'> <'\tfoo1.6\n'> <'\tfoo1.3\n'> <'\tEOF\n'> 
          <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)