(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'pushing to a repository using push options'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: mk_repo_pair
      body: 
        (BraceGroup
          children: [
            (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)})
                (Subshell
                  child: 
                    (CommandList
                      children: [
                        (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)})
                            (SimpleCommand
                              words: [{(cat)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: 16777215
                                  arg_word: {(.git/hooks/pre-receive)}
                                  spids: [80]
                                )
                                (HereDoc
                                  op_id: Redir_DLessDash
                                  fd: 16777215
                                  body: 
                                    {('#!/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')
                                    }
                                  do_expansion: False
                                  here_end: EOF
                                  was_filled: T
                                  spids: [83]
                                )
                              ]
                            )
                            (C {(chmod)} {(u) (Lit_Other '+') (x)} {(.git/hooks/pre-receive)})
                          ]
                        )
                        (AndOr
                          ops: [Op_DAmp]
                          children: [
                            (SimpleCommand
                              words: [{(cat)}]
                              redirects: [
                                (Redir
                                  op_id: Redir_Great
                                  fd: 16777215
                                  arg_word: {(.git/hooks/post-receive)}
                                  spids: [103]
                                )
                                (HereDoc
                                  op_id: Redir_DLessDash
                                  fd: 16777215
                                  body: 
                                    {('#!/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')
                                    }
                                  do_expansion: False
                                  here_end: EOF
                                  was_filled: T
                                  spids: [106]
                                )
                              ]
                            )
                            (C {(chmod)} {(u) (Lit_Other '+') (x)} {(.git/hooks/post-receive)})
                          ]
                        )
                      ]
                    )
                  spids: [48 123]
                )
                (Subshell
                  child: 
                    (AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(cd)} {(workbench)})
                        (C {(git)} {(remote)} {(add)} {(up)} {(../upstream)})
                      ]
                    )
                  spids: [128 149]
                )
              ]
            )
          ]
          spids: [20]
        )
      spids: [15 19]
    )
    (FuncDef
      name: test_refs
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (C {(test)} {($ VSub_Pound '$#')} {(Lit_Other '=')} {(2)})
                (SimpleCommand
                  words: [{(git)} {(-C)} {(upstream)} {(rev-parse)} {(--verify)} {(DQ ($ VSub_Number '$1'))}]
                  redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(expect)} spids:[193])]
                )
                (SimpleCommand
                  words: [
                    {(git)}
                    {(-C)}
                    {(workbench)}
                    {(rev-parse)}
                    {(--verify)}
                    {(DQ ($ VSub_Number '$2'))}
                  ]
                  redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(actual)} spids:[213])]
                )
                (C {(test_cmp)} {(expect)} {(actual)})
              ]
            )
          ]
          spids: [165]
        )
      spids: [160 164]
    )
    (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)})
  ]
)