(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'fetch handles conflicting refspecs correctly'>)}
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:D)
          op: Equal
          rhs: 
            {
              (word_part.CommandSubPart
                command_list: (command.CommandList children:[(C {(pwd)})])
                left_token: <Left_CommandSub '$('>
              )
            }
        )
      ]
    )
    (command.FuncDef
      name: setup_repository
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (C {(git)} {(init)} {(DQ ($ VSub_Number '$1'))})
                (command.Subshell
                  command_list: 
                    (command.CommandList
                      children: [
                        (command.AndOr
                          ops: [Op_DAmp Op_DAmp Op_DAmp]
                          children: [
                            (C {(cd)} {(DQ ($ VSub_Number '$1'))})
                            (C {(git)} {(config)} {(remote.origin.url)} {(DQ ($ VSub_DollarName '$D'))})
                            (C {(shift)})
                            (command.ForEach
                              iter_name: refspec
                              iter_words: [{(DQ ($ VSub_At '$@'))}]
                              do_arg_iter: F
                              body: 
                                (command.DoGroup
                                  children: [
                                    (C {(git)} {(config)} {(--add)} {(remote.origin.fetch)} 
                                      {(DQ ($ VSub_DollarName '$refspec'))}
                                    )
                                  ]
                                )
                            )
                          ]
                        )
                      ]
                    )
                )
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: verify_stderr
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp]
              children: [
                (command.SimpleCommand
                  words: [{(cat)}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expected)})]
                )
                (command.Pipeline
                  children: [
                    (command.SimpleCommand
                      words: [{(test_i18ngrep)} {(-E)} {(SQ <'^(fatal|warning):'>)}]
                      redirects: [(redir.Redir op:<Redir_Less '<'> fd:16777215 arg_word:{(error)})]
                    )
                    (command.SimpleCommand
                      words: [{(grep)} {(-v)} {(SQ <'hung up'>)}]
                      redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual)})]
                    )
                    (C {(sort)})
                  ]
                  negated: F
                )
                (C {(test_i18ncmp)} {(expected)} {(actual)})
              ]
            )
          ]
        )
    )
    (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)})
  ]
)