(command.CommandList
  children: [
    (command.Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (lhs_expr.LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'selecting remote repo in ambiguous cases'>)}
        )
      ]
    )
    (C {(.)} {(./test-lib.sh)})
    (command.FuncDef
      name: reset
      body: 
        (command.BraceGroup
          children: [(C {(rm)} {(-rf)} {(foo)} {(foo.git)} {(fetch)} {(clone)})]
        )
    )
    (command.FuncDef
      name: make_tree
      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]
                          children: [
                            (C {(cd)} {(DQ ($ VSub_Number '$1'))})
                            (C {(test_commit)} {(DQ ($ VSub_Number '$1'))})
                          ]
                        )
                      ]
                    )
                )
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: make_bare
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp]
              children: [
                (C {(git)} {(init)} {(--bare)} {(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'))})
                            (command.Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (lhs_expr.LhsName name:tree)
                                  op: Equal
                                  rhs: 
                                    {
                                      (word_part.CommandSubPart
                                        command_list: 
                                          (command.CommandList
                                            children: [
                                              (C {(git)} {(hash-object)} {(-w)} {(-t)} {(tree)} 
                                                {(/dev/null)}
                                              )
                                            ]
                                          )
                                        left_token: <Left_CommandSub '$('>
                                      )
                                    }
                                )
                              ]
                            )
                            (command.Assignment
                              keyword: Assign_None
                              pairs: [
                                (assign_pair
                                  lhs: (lhs_expr.LhsName name:commit)
                                  op: Equal
                                  rhs: 
                                    {
                                      (word_part.CommandSubPart
                                        command_list: 
                                          (command.CommandList
                                            children: [
                                              (command.Pipeline
                                                children: [
                                                  (C {(echo)} {(DQ ($ VSub_Number '$1'))})
                                                  (C {(git)} {(commit-tree)} 
                                                    {($ VSub_DollarName '$tree')}
                                                  )
                                                ]
                                                negated: F
                                              )
                                            ]
                                          )
                                        left_token: <Left_CommandSub '$('>
                                      )
                                    }
                                )
                              ]
                            )
                            (C {(git)} {(update-ref)} {(HEAD)} {($ VSub_DollarName '$commit')})
                          ]
                        )
                      ]
                    )
                )
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: get
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp]
              children: [
                (C {(git)} {(init)} {(--bare)} {(fetch)})
                (command.Subshell
                  command_list: 
                    (command.CommandList
                      children: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (C {(cd)} {(fetch)})
                            (C {(git)} {(fetch)} {(DQ (../) ($ VSub_Number '$1'))})
                          ]
                        )
                      ]
                    )
                )
                (C {(git)} {(clone)} {(DQ ($ VSub_Number '$1'))} {(clone)})
              ]
            )
          ]
        )
    )
    (command.FuncDef
      name: check
      body: 
        (command.BraceGroup
          children: [
            (command.AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (command.SimpleCommand
                  words: [{(echo)} {(DQ ($ VSub_Number '$1'))}]
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(expect)})]
                )
                (command.Subshell
                  command_list: 
                    (command.CommandList
                      children: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (C {(cd)} {(fetch)})
                            (C {(git)} {(log)} {(-1)} {(--format) (Lit_Other '=') (Lit_Other '%') (s)} 
                              {(FETCH_HEAD)}
                            )
                          ]
                        )
                      ]
                    )
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual.fetch)})]
                )
                (command.Subshell
                  command_list: 
                    (command.CommandList
                      children: [
                        (command.AndOr
                          ops: [Op_DAmp]
                          children: [
                            (C {(cd)} {(clone)})
                            (C {(git)} {(log)} {(-1)} {(--format) (Lit_Other '=') (Lit_Other '%') (s)} 
                              {(HEAD)}
                            )
                          ]
                        )
                      ]
                    )
                  redirects: [(redir.Redir op:<Redir_Great '>'> fd:16777215 arg_word:{(actual.clone)})]
                )
                (C {(test_cmp)} {(expect)} {(actual.fetch)})
                (C {(test_cmp)} {(expect)} {(actual.clone)})
              ]
            )
          ]
        )
    )
    (C {(test_expect_success)} {(SQ <'find .git dir in worktree'>)} 
      {(SQ <'\n'> <'\treset &&\n'> <'\tmake_tree foo &&\n'> <'\tget foo &&\n'> <'\tcheck foo\n'>)}
    )
    (C {(test_expect_success)} {(SQ <'automagically add .git suffix'>)} 
      {
        (SQ <'\n'> <'\treset &&\n'> <'\tmake_bare foo.git &&\n'> <'\tget foo &&\n'> <'\tcheck foo.git\n'>)
      }
    )
    (C {(test_expect_success)} {(SQ <'automagically add .git suffix to worktree'>)} 
      {
        (SQ <'\n'> <'\treset &&\n'> <'\tmake_tree foo.git &&\n'> <'\tget foo &&\n'> <'\tcheck foo.git\n'>)
      }
    )
    (C {(test_expect_success)} {(SQ <'prefer worktree foo over bare foo.git'>)} 
      {
        (SQ <'\n'> <'\treset &&\n'> <'\tmake_tree foo &&\n'> <'\tmake_bare foo.git &&\n'> 
          <'\tget foo &&\n'> <'\tcheck foo\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'prefer bare foo over bare foo.git'>)} 
      {
        (SQ <'\n'> <'\treset &&\n'> <'\tmake_bare foo &&\n'> <'\tmake_bare foo.git &&\n'> 
          <'\tget foo &&\n'> <'\tcheck foo\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'disambiguate with full foo.git'>)} 
      {
        (SQ <'\n'> <'\treset &&\n'> <'\tmake_bare foo &&\n'> <'\tmake_bare foo.git &&\n'> 
          <'\tget foo.git &&\n'> <'\tcheck foo.git\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'we are not fooled by non-git foo directory'>)} 
      {
        (SQ <'\n'> <'\treset &&\n'> <'\tmake_bare foo.git &&\n'> <'\tmkdir foo &&\n'> <'\tget foo &&\n'> 
          <'\tcheck foo.git\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'prefer inner .git over outer bare'>)} 
      {
        (SQ <'\n'> <'\treset &&\n'> <'\tmake_tree foo &&\n'> <'\tmake_bare foo.git &&\n'> 
          <'\tmv foo/.git foo.git &&\n'> <'\tget foo.git &&\n'> <'\tcheck foo\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)