(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description spids:[12])
          op: Equal
          rhs: {(SQ <'pushing to a repository using push options'>)}
          spids: [12]
        )
      ]
      spids: [12]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.FuncDef
      name: mk_repo_pair
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (C {(rm)} {(-rf)} {(workbench)} {(upstream)})
                (C {(test_create_repo)} {(upstream)})
                (C {(test_create_repo)} {(workbench)})
                (command.Subshell
                  child: 
                    (command.CommandList
                      children: [
                        (command.AndOr
                          ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
                          children: [
                            (C {(cd)} {(upstream)})
                            (C {(git)} {(config)} {(receive.denyCurrentBranch)} {(warn)})
                            (C {(mkdir)} {(-p)} {(.git/hooks)})
                            (command.SimpleCommand
                              words: [{(cat)}]
                              redirects: [
                                (redir.Redir
                                  op: <Redir_Great '>'>
                                  fd: 16777215
                                  arg_word: {(.git/hooks/pre-receive)}
                                )
                                (redir.HereDoc
                                  op: <Redir_DLessDash '<<-'>
                                  fd: 16777215
                                  here_begin: {(SQ <EOF>)}
                                  here_end_span_id: 108
                                  stdin_parts: [
                                    ('#!/bin/sh\n')
                                    ('if test -n "$GIT_PUSH_OPTION_COUNT"; then\n')
                                    ('i=0\n')
                                    ('>hooks/pre-receive.push_options\n')
                                    ('while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"; do\n')
                                    ('eval "value=\\$GIT_PUSH_OPTION_$i"\n')
                                    ('echo $value >>hooks/pre-receive.push_options\n')
                                    ('i=$((i + 1))\n')
                                    ('done\n')
                                    ('fi\n')
                                  ]
                                )
                              ]
                            )
                            (C {(chmod)} {(u) (Lit_Other '+') (x)} {(.git/hooks/pre-receive)})
                          ]
                        )
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (command.SimpleCommand
                              words: [{(cat)}]
                              redirects: [
                                (redir.Redir
                                  op: <Redir_Great '>'>
                                  fd: 16777215
                                  arg_word: {(.git/hooks/post-receive)}
                                )
                                (redir.HereDoc
                                  op: <Redir_DLessDash '<<-'>
                                  fd: 16777215
                                  here_begin: {(SQ <EOF>)}
                                  here_end_span_id: 142
                                  stdin_parts: [
                                    ('#!/bin/sh\n')
                                    ('if test -n "$GIT_PUSH_OPTION_COUNT"; then\n')
                                    ('i=0\n')
                                    ('>hooks/post-receive.push_options\n')
                                    ('while test "$i" -lt "$GIT_PUSH_OPTION_COUNT"; do\n')
                                    ('eval "value=\\$GIT_PUSH_OPTION_$i"\n')
                                    ('echo $value >>hooks/post-receive.push_options\n')
                                    ('i=$((i + 1))\n')
                                    ('done\n')
                                    ('fi\n')
                                  ]
                                )
                              ]
                            )
                            (C {(chmod)} {(u) (Lit_Other '+') (x)} {(.git/hooks/post-receive)})
                          ]
                        )
                      ]
                    )
                  spids: [56 153]
                )
                (command.Subshell
                  child: 
                    (command.AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(cd)} {(workbench)})
                        (C {(git)} {(remote)} {(add)} {(up)} {(../upstream)})
                      ]
                    )
                  spids: [158 179]
                )
              ]
            )
          ]
          spids: [28]
        )
      spids: [23 27]
    )
    (command.FuncDef
      name: test_refs
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (C {(test)} {($ VSub_Pound '$#')} {(Lit_Other '=')} {(2)})
                (command.SimpleCommand
                  words: [{(git)} {(-C)} {(upstream)} {(rev-parse)} {(--verify)} {(DQ ($ VSub_Number '$1'))}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})]
                )
                (command.SimpleCommand
                  words: [
                    {(git)}
                    {(-C)}
                    {(workbench)}
                    {(rev-parse)}
                    {(--verify)}
                    {(DQ ($ VSub_Number '$2'))}
                  ]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual)})]
                )
                (C {(test_cmp)} {(expect)} {(actual)})
              ]
            )
          ]
          spids: [195]
        )
      spids: [190 194]
    )
    (C {(test_expect_success)} {(SQ <'one push option works for a single branch'>)} 
      {
        (SQ <'\n'> <'\tmk_repo_pair &&\n'> 
          <'\tgit -C upstream config receive.advertisePushOptions true &&\n'> <'\t(\n'> <'\t\tcd workbench &&\n'> <'\t\ttest_commit one &&\n'> <'\t\tgit push --mirror up &&\n'> 
          <'\t\ttest_commit two &&\n'> <'\t\tgit push --push-option=asdf up master\n'> <'\t) &&\n'> <'\ttest_refs master master &&\n'> 
          <'\techo "asdf" >expect &&\n'> <'\ttest_cmp expect upstream/.git/hooks/pre-receive.push_options &&\n'> 
          <'\ttest_cmp expect upstream/.git/hooks/post-receive.push_options\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'push option denied by remote'>)} 
      {
        (SQ <'\n'> <'\tmk_repo_pair &&\n'> 
          <'\tgit -C upstream config receive.advertisePushOptions false &&\n'> <'\t(\n'> <'\t\tcd workbench &&\n'> <'\t\ttest_commit one &&\n'> <'\t\tgit push --mirror up &&\n'> 
          <'\t\ttest_commit two &&\n'> <'\t\ttest_must_fail git push --push-option=asdf up master\n'> <'\t) &&\n'> 
          <'\ttest_refs master HEAD@{1}\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'two push options work'>)} 
      {
        (SQ <'\n'> <'\tmk_repo_pair &&\n'> 
          <'\tgit -C upstream config receive.advertisePushOptions true &&\n'> <'\t(\n'> <'\t\tcd workbench &&\n'> <'\t\ttest_commit one &&\n'> <'\t\tgit push --mirror up &&\n'> 
          <'\t\ttest_commit two &&\n'> <'\t\tgit push --push-option=asdf --push-option="more structured text" up master\n'> <'\t) &&\n'> 
          <'\ttest_refs master master &&\n'> <'\tprintf "asdf\\nmore structured text\\n" >expect &&\n'> 
          <'\ttest_cmp expect upstream/.git/hooks/pre-receive.push_options &&\n'> <'\ttest_cmp expect upstream/.git/hooks/post-receive.push_options\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)