(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'selecting remote repo in ambiguous cases'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (FuncDef
      name: reset
      body: 
        (BraceGroup
          children: [(C {(rm)} {(-rf)} {(foo)} {(foo.git)} {(fetch)} {(clone)})]
          spids: [18]
        )
      spids: [14 17]
    )
    (FuncDef
      name: make_tree
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp]
              children: [
                (C {(git)} {(init)} {(DQ ($ VSub_Number '$1'))})
                (Subshell
                  child: 
                    (AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(cd)} {(DQ ($ VSub_Number '$1'))})
                        (C {(test_commit)} {(DQ ($ VSub_Number '$1'))})
                      ]
                    )
                  spids: [54 68]
                )
              ]
            )
          ]
          spids: [40]
        )
      spids: [36 39]
    )
    (FuncDef
      name: make_bare
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp]
              children: [
                (C {(git)} {(init)} {(--bare)} {(DQ ($ VSub_Number '$1'))})
                (Subshell
                  child: 
                    (AndOr
                      ops: [Op_DAmp Op_DAmp Op_DAmp]
                      children: [
                        (C {(cd)} {(DQ ($ VSub_Number '$1'))})
                        (Assignment
                          keyword: Assign_None
                          pairs: [
                            (assign_pair
                              lhs: (LhsName name:tree)
                              op: Equal
                              rhs: 
                                {
                                  (CommandSubPart
                                    command_list: 
                                      (CommandList
                                        children: [
                                          (C {(git)} {(hash-object)} {(-w)} {(-t)} {(tree)} {(/dev/null)})
                                        ]
                                      )
                                    left_token: <Left_CommandSub '$('>
                                    spids: [104 116]
                                  )
                                }
                              spids: [103]
                            )
                          ]
                          spids: [103]
                        )
                        (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: F
                                          )
                                        ]
                                      )
                                    left_token: <Left_CommandSub '$('>
                                    spids: [122 136]
                                  )
                                }
                              spids: [121]
                            )
                          ]
                          spids: [121]
                        )
                        (C {(git)} {(update-ref)} {(HEAD)} {($ VSub_Name '$commit')})
                      ]
                    )
                  spids: [93 150]
                )
              ]
            )
          ]
          spids: [77]
        )
      spids: [73 76]
    )
    (FuncDef
      name: get
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp Op_DAmp]
              children: [
                (C {(git)} {(init)} {(--bare)} {(fetch)})
                (Subshell
                  child: 
                    (AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(cd)} {(fetch)})
                        (C {(git)} {(fetch)} {(DQ (../) ($ VSub_Number '$1'))})
                      ]
                    )
                  spids: [173 188]
                )
                (C {(git)} {(clone)} {(DQ ($ VSub_Number '$1'))} {(clone)})
              ]
            )
          ]
          spids: [159]
        )
      spids: [155 158]
    )
    (FuncDef
      name: check
      body: 
        (BraceGroup
          children: [
            (AndOr
              ops: [Op_DAmp Op_DAmp Op_DAmp Op_DAmp]
              children: [
                (SimpleCommand
                  words: [{(echo)} {(DQ ($ VSub_Number '$1'))}]
                  redirects: [(Redir op_id:Redir_Great fd:16777215 arg_word:{(expect)} spids:[219])]
                )
                (Subshell
                  child: 
                    (AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(cd)} {(fetch)})
                        (C {(git)} {(log)} {(-1)} {(--format) (Lit_Other '=') (Lit_Other '%') (s)} 
                          {(FETCH_HEAD)}
                        )
                      ]
                    )
                  redirects: [
                    (Redir
                      op_id: Redir_Great
                      fd: 16777215
                      arg_word: {(actual.fetch)}
                      spids: [246]
                    )
                  ]
                  spids: [225 244]
                )
                (Subshell
                  child: 
                    (AndOr
                      ops: [Op_DAmp]
                      children: [
                        (C {(cd)} {(clone)})
                        (C {(git)} {(log)} {(-1)} {(--format) (Lit_Other '=') (Lit_Other '%') (s)} 
                          {(HEAD)}
                        )
                      ]
                    )
                  redirects: [
                    (Redir
                      op_id: Redir_Great
                      fd: 16777215
                      arg_word: {(actual.clone)}
                      spids: [273]
                    )
                  ]
                  spids: [252 271]
                )
                (C {(test_cmp)} {(expect)} {(actual.fetch)})
                (C {(test_cmp)} {(expect)} {(actual.clone)})
              ]
            )
          ]
          spids: [210]
        )
      spids: [206 209]
    )
    (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)})
  ]
)