(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"send-pack --stdin tests">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: create_ref
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (Assignment
                  keyword: Assign_None
                  pairs: [
                    (assign_pair
                      lhs: (LhsName name:tree)
                      op: Equal
                      rhs: 
                        {
                          (CommandSubPart
                            command_list: (CommandList children:[(C {(git)} {(write-tree)})])
                            left_token: <Left_CommandSub "$(">
                            spids: [23 27]
                          )
                        }
                      spids: [22]
                    )
                  ]
                  spids: [22]
                )
                (AndOr
                  children: [
                    (C {(test_tick)})
                    (AndOr
                      children: [
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:commit)
                              op: Equal
                              rhs: 
                                {
                                  (CommandSubPart
                                    command_list: 
                                      (CommandList
                                        children: [
                                          (Pipeline
                                            children: [
                                              (C {(echo)} {(DQ ($ VSub_Number "$1"))})
                                              (C {(git)} {(commit-tree)} {($ VSub_Name "$tree")})
                                            ]
                                            negated: False
                                          )
                                        ]
                                      )
                                    left_token: <Left_CommandSub "$(">
                                    spids: [38 52]
                                  )
                                }
                              spids: [37]
                            )
                          ]
                          spids: [37]
                        )
                        (C {(git)} {(update-ref)} {(DQ ($ VSub_Number "$1"))} {($ VSub_Name "$commit")})
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [19]
        )
      spids: [14 18]
    )
    (FuncDef
      name: clear_remote
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(rm)} {(-rf)} {(remote.git)})
                (C {(git)} {(init)} {(--bare)} {(remote.git)})
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [75]
        )
      spids: [70 74]
    )
    (FuncDef
      name: verify_push
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [{(git)} {(rev-parse)} {(DQ ($ VSub_Number "$1"))}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[114])]
                )
                (AndOr
                  children: [
                    (SimpleCommand
                      words: [
                        {(git)}
                        {(--git-dir) (Lit_Other "=") (remote.git)}
                        {(rev-parse)}
                        {
                          (DQ 
                            (BracedVarSub
                              token: <VSub_Number 2>
                              suffix_op: 
                                (StringUnary
                                  op_id: VTest_ColonHyphen
                                  arg_word: {($ VSub_Number "$1")}
                                )
                              spids: [129 133]
                            )
                          )
                        }
                      ]
                      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(actual)} spids:[136])]
                    )
                    (C {(test_cmp)} {(expect)} {(actual)})
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [103]
        )
      spids: [98 102]
    )
    (C {(test_expect_success)} {(SQ <"setup refs">)} 
      {
        (SQ <"\n"> <"\tcat >refs <<-\\EOF &&\n"> <"\trefs/heads/A\n"> <"\trefs/heads/C\n"> 
          <"\trefs/tags/D\n"> <"\trefs/heads/B\n"> <"\trefs/tags/E\n"> <"\tEOF\n"> <"\tfor i in $(cat refs); do\n"> 
          <"\t\tcreate_ref $i || return 1\n"> <"\tdone\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"refs on cmdline">)} 
      {
        (SQ <"\n"> <"\tclear_remote &&\n"> <"\tgit send-pack remote.git $(cat refs) &&\n"> 
          <"\tfor i in $(cat refs); do\n"> <"\t\tverify_push $i || return 1\n"> <"\tdone\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"refs over stdin">)} 
      {
        (SQ <"\n"> <"\tclear_remote &&\n"> <"\tgit send-pack remote.git --stdin <refs &&\n"> 
          <"\tfor i in $(cat refs); do\n"> <"\t\tverify_push $i || return 1\n"> <"\tdone\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"stdin lines are full refspecs">)} 
      {
        (SQ <"\n"> <"\tclear_remote &&\n"> <"\techo \"A:other\" >input &&\n"> 
          <"\tgit send-pack remote.git --stdin <input &&\n"> <"\tverify_push refs/heads/A refs/heads/other\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"stdin mixed with cmdline">)} 
      {
        (SQ <"\n"> <"\tclear_remote &&\n"> <"\techo A >input &&\n"> 
          <"\tgit send-pack remote.git --stdin B <input &&\n"> <"\tverify_push A &&\n"> <"\tverify_push B\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"cmdline refs written in order">)} 
      {
        (SQ <"\n"> <"\tclear_remote &&\n"> 
          <"\ttest_must_fail git send-pack remote.git A:foo B:foo &&\n"> <"\tverify_push A foo\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"--stdin refs come after cmdline">)} 
      {
        (SQ <"\n"> <"\tclear_remote &&\n"> <"\techo A:foo >input &&\n"> 
          <"\ttest_must_fail git send-pack remote.git --stdin B:foo <input &&\n"> <"\tverify_push B foo\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"refspecs and --mirror do not mix (cmdline)">)} 
      {
        (SQ <"\n"> <"\tclear_remote &&\n"> 
          <"\ttest_must_fail git send-pack remote.git --mirror $(cat refs)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"refspecs and --mirror do not mix (stdin)">)} 
      {
        (SQ <"\n"> <"\tclear_remote &&\n"> 
          <"\ttest_must_fail git send-pack remote.git --mirror --stdin <refs\n">
        )
      }
    )
    (C {(test_done)})
  ]
)