(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'git remote group handling'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (command.ShFunction
      name: mark
      body: 
        (BraceGroup
          children: [
            (command.Simple
              words: [{<echo>} {(DQ ($ Id.VSub_Number '$1'))}]
              redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<mark>})]
              do_fork: T
            )
          ]
        )
    )
    (command.ShFunction
      name: update_repo
      body: 
        (BraceGroup
          children: [
            (command.Subshell
              child: 
                (command.AndOr
                  ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
                  children: [
                    (C {<cd>} {($ Id.VSub_Number '$1')})
                    (command.Simple
                      words: [{<echo>} {<content>}]
                      redirects: [
                        (redir
                          op: <Id.Redir_DGreat '>>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: {<file>}
                        )
                      ]
                      do_fork: T
                    )
                    (C {<git>} {<add>} {<file>})
                    (C {<git>} {<commit>} {<-F>} {<'../mark'>})
                  ]
                )
            )
          ]
        )
    )
    (command.ShFunction
      name: update_repos
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (C {<update_repo>} {<one>} {($ Id.VSub_Number '$1')})
                (C {<update_repo>} {<two>} {($ Id.VSub_Number '$1')})
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: repo_fetched
      body: 
        (BraceGroup
          children: [
            (command.If
              arms: [
                (if_arm
                  cond: 
                    (condition.Shell
                      commands: [
                        (command.Sentence
                          child: 
                            (C {<test>} 
                              {
                                (DQ 
                                  (command_sub
                                    left_token: <Id.Left_DollarParen '$('>
                                    child: 
                                      (C {<git>} {<log>} {<-1>} 
                                        {<--pretty> <Id.Lit_Equals '='> <format> <Id.Lit_Colon ':'> 
                                          <Id.Lit_Other '%'> <s>
                                        } {($ Id.VSub_Number '$1')} {<-->}
                                      )
                                  )
                                )
                              } {<Id.Lit_Equals '='>} {(DQ (command_sub left_token:<Id.Left_DollarParen '$('> child:(C {<cat>} {<mark>})))}
                            )
                          terminator: <Id.Op_Semi _>
                        )
                      ]
                    )
                  action: [
                    (command.Simple
                      words: [{<echo>} {(DQ <'repo was fetched: '> ($ Id.VSub_Number '$1'))}]
                      redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
                      do_fork: T
                    )
                    (command.ControlFlow
                      token: <Id.ControlFlow_Return return>
                      arg_word: {<0>}
                    )
                  ]
                  spids: [111 147]
                )
              ]
            )
            (command.Simple
              words: [{<echo>} {(DQ <'repo was not fetched: '> ($ Id.VSub_Number '$1'))}]
              redirects: [(redir op:<Id.Redir_GreatAnd '>&'> loc:(redir_loc.Fd fd:1) arg:{<2>})]
              do_fork: T
            )
            (command.ControlFlow token:<Id.ControlFlow_Return return> arg_word:{<1>})
          ]
        )
    )
    (C {<test_expect_success>} {(SQ <setup>)} 
      {
        (SQ <'\n'> <'\tmkdir one && (cd one && git init) &&\n'> 
          <'\tmkdir two && (cd two && git init) &&\n'> <'\tgit remote add -m master one one &&\n'> <'\tgit remote add -m master two two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'no group updates all'>)} 
      {
        (SQ <'\n'> <'\tmark update-all &&\n'> <'\tupdate_repos &&\n'> <'\tgit remote update &&\n'> 
          <'\trepo_fetched one &&\n'> <'\trepo_fetched two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'nonexistent group produces error'>)} 
      {
        (SQ <'\n'> <'\tmark nonexistent &&\n'> <'\tupdate_repos &&\n'> 
          <'\ttest_must_fail git remote update nonexistent &&\n'> <'\t! repo_fetched one &&\n'> <'\t! repo_fetched two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'updating group updates all members (remote update)'>)} 
      {
        (SQ <'\n'> <'\tmark group-all &&\n'> <'\tupdate_repos &&\n'> 
          <'\tgit config --add remotes.all one &&\n'> <'\tgit config --add remotes.all two &&\n'> <'\tgit remote update all &&\n'> 
          <'\trepo_fetched one &&\n'> <'\trepo_fetched two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'updating group updates all members (fetch)'>)} 
      {
        (SQ <'\n'> <'\tmark fetch-group-all &&\n'> <'\tupdate_repos &&\n'> <'\tgit fetch all &&\n'> 
          <'\trepo_fetched one &&\n'> <'\trepo_fetched two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'updating group does not update non-members (remote update)'>)} 
      {
        (SQ <'\n'> <'\tmark group-some &&\n'> <'\tupdate_repos &&\n'> 
          <'\tgit config --add remotes.some one &&\n'> <'\tgit remote update some &&\n'> <'\trepo_fetched one &&\n'> <'\t! repo_fetched two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'updating group does not update non-members (fetch)'>)} 
      {
        (SQ <'\n'> <'\tmark fetch-group-some &&\n'> <'\tupdate_repos &&\n'> 
          <'\tgit config --add remotes.some one &&\n'> <'\tgit remote update some &&\n'> <'\trepo_fetched one &&\n'> <'\t! repo_fetched two\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'updating remote name updates that remote'>)} 
      {
        (SQ <'\n'> <'\tmark remote-name &&\n'> <'\tupdate_repos &&\n'> <'\tgit remote update one &&\n'> 
          <'\trepo_fetched one &&\n'> <'\t! repo_fetched two\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)