(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <"fetch handles conflicting refspecs correctly">)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:D)
          op: Equal
          rhs: 
            {
              (CommandSubPart
                command_list: (CommandList children:[(C {(pwd)})])
                left_token: <Left_CommandSub "$(">
                spids: [16 18]
              )
            }
          spids: [15]
        )
      ]
      spids: [15]
    )
    (FuncDef
      name: setup_repository
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(git)} {(init)} {(DQ ($ VSub_Number "$1"))})
                (Subshell
                  child: 
                    (AndOr
                      children: [
                        (C {(cd)} {(DQ ($ VSub_Number "$1"))})
                        (AndOr
                          children: [
                            (C {(git)} {(config)} {(remote.origin.url)} {(DQ ($ VSub_Name "$D"))})
                            (AndOr
                              children: [
                                (C {(shift)})
                                (ForEach
                                  iter_name: refspec
                                  iter_words: [{(DQ ($ VSub_At "$@"))}]
                                  do_arg_iter: False
                                  body: 
                                    (DoGroup
                                      children: [
                                        (C {(git)} {(config)} {(--add)} {(remote.origin.fetch)} 
                                          {(DQ ($ VSub_Name "$refspec"))}
                                        )
                                      ]
                                      spids: [80 96]
                                    )
                                  spids: [74 -1]
                                )
                              ]
                              op_id: Op_DAmp
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  spids: [39 99]
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [26]
        )
      spids: [21 25]
    )
    (FuncDef
      name: verify_stderr
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [{(cat)}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expected)} spids:[114])]
                )
                (AndOr
                  children: [
                    (Pipeline
                      children: [
                        (SimpleCommand
                          words: [{(test_i18ngrep)} {(-E)} {(SQ <"^(fatal|warning):">)}]
                          redirects: [(Redir op_id:Redir_Less fd:-1 arg_word:{(error)} spids:[136])]
                        )
                        (SimpleCommand
                          words: [{(grep)} {(-v)} {(SQ <"hung up">)}]
                          redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(actual)} spids:[149])]
                        )
                        (C {(sort)})
                      ]
                      negated: False
                    )
                    (C {(test_i18ncmp)} {(expected)} {(actual)})
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [109]
        )
      spids: [104 108]
    )
    (C {(test_expect_success)} {(SQ <setup>)} 
      {
        (SQ <"\n"> <"\tgit commit --allow-empty -m \"Initial\" &&\n"> <"\tgit branch branch1 &&\n"> 
          <"\tgit tag tag1 &&\n"> <"\tgit commit --allow-empty -m \"First\" &&\n"> <"\tgit branch branch2 &&\n"> <"\tgit tag tag2\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"fetch with no conflict">)} 
      {
        (SQ <"\n"> <"\tsetup_repository ok \"+refs/heads/*:refs/remotes/origin/*\" && (\n"> 
          <"\t\tcd ok &&\n"> <"\t\tgit fetch origin\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"fetch conflict: config vs. config">)} 
      {
        (SQ <"\n"> <"\tsetup_repository ccc \\\n"> 
          <"\t\t\"+refs/heads/branch1:refs/remotes/origin/branch1\" \\\n"> <"\t\t\"+refs/heads/branch2:refs/remotes/origin/branch1\" && (\n"> <"\t\tcd ccc &&\n"> 
          <"\t\ttest_must_fail git fetch origin 2>error &&\n"> <"\t\tverify_stderr <<-\\EOF\n"> 
          <
"\t\tfatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1\n"
          > <"\t\tEOF\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"fetch duplicate: config vs. config">)} 
      {
        (SQ <"\n"> <"\tsetup_repository dcc \\\n"> <"\t\t\"+refs/heads/*:refs/remotes/origin/*\" \\\n"> 
          <"\t\t\"+refs/heads/branch1:refs/remotes/origin/branch1\" && (\n"> <"\t\tcd dcc &&\n"> <"\t\tgit fetch origin\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"fetch conflict: arg overrides config">)} 
      {
        (SQ <"\n"> <"\tsetup_repository aoc \\\n"> 
          <"\t\t\"+refs/heads/*:refs/remotes/origin/*\" && (\n"> <"\t\tcd aoc &&\n"> <"\t\tgit fetch origin refs/heads/branch2:refs/remotes/origin/branch1\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"fetch conflict: arg vs. arg">)} 
      {
        (SQ <"\n"> <"\tsetup_repository caa && (\n"> <"\t\tcd caa &&\n"> 
          <"\t\ttest_must_fail git fetch origin \\\n"> <"\t\t\trefs/heads/*:refs/remotes/origin/* \\\n"> 
          <"\t\t\trefs/heads/branch2:refs/remotes/origin/branch1 2>error &&\n"> <"\t\tverify_stderr <<-\\EOF\n"> 
          <
"\t\tfatal: Cannot fetch both refs/heads/branch1 and refs/heads/branch2 to refs/remotes/origin/branch1\n"
          > <"\t\tEOF\n"> <"\t)\n">
        )
      }
    )
    (C {(test_expect_success)} {(SQ <"fetch conflict: criss-cross args">)} 
      {
        (SQ <"\n"> <"\tsetup_repository xaa \\\n"> 
          <"\t\t\"+refs/heads/*:refs/remotes/origin/*\" && (\n"> <"\t\tcd xaa &&\n"> <"\t\tgit fetch origin \\\n"> 
          <"\t\t\trefs/heads/branch1:refs/remotes/origin/branch2 \\\n"> <"\t\t\trefs/heads/branch2:refs/remotes/origin/branch1 2>error &&\n"> <"\t\tverify_stderr <<-\\EOF\n"> 
          <
"\t\twarning: refs/remotes/origin/branch1 usually tracks refs/heads/branch1, not refs/heads/branch2\n"
          > 
          <
"\t\twarning: refs/remotes/origin/branch2 usually tracks refs/heads/branch2, not refs/heads/branch1\n"
          > <"\t\tEOF\n"> <"\t)\n">
        )
      }
    )
    (C {(test_done)})
  ]
)