(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
              children: [
                (C {(git)} {(init)} {(DQ ($ VSub_Number '$1'))})
                (Subshell
                  child: 
                    (AndOr
                      children: [
                        (C {(cd)} {(DQ ($ VSub_Number '$1'))})
                        (C {(test_commit)} {(DQ ($ VSub_Number '$1'))})
                      ]
                      op_id: Op_DAmp
                    )
                  spids: [54 68]
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [40]
        )
      spids: [36 39]
    )
    (FuncDef
      name: make_bare
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(git)} {(init)} {(--bare)} {(DQ ($ VSub_Number '$1'))})
                (Subshell
                  child: 
                    (AndOr
                      children: [
                        (C {(cd)} {(DQ ($ VSub_Number '$1'))})
                        (AndOr
                          children: [
                            (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]
                            )
                            (AndOr
                              children: [
                                (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: False
                                                  )
                                                ]
                                              )
                                            left_token: <Left_CommandSub '$('>
                                            spids: [122 136]
                                          )
                                        }
                                      spids: [121]
                                    )
                                  ]
                                  spids: [121]
                                )
                                (C {(git)} {(update-ref)} {(HEAD)} {($ VSub_Name '$commit')})
                              ]
                              op_id: Op_DAmp
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  spids: [93 150]
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [77]
        )
      spids: [73 76]
    )
    (FuncDef
      name: get
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(git)} {(init)} {(--bare)} {(fetch)})
                (AndOr
                  children: [
                    (Subshell
                      child: 
                        (AndOr
                          children: [
                            (C {(cd)} {(fetch)})
                            (C {(git)} {(fetch)} {(DQ (../) ($ VSub_Number '$1'))})
                          ]
                          op_id: Op_DAmp
                        )
                      spids: [173 188]
                    )
                    (C {(git)} {(clone)} {(DQ ($ VSub_Number '$1'))} {(clone)})
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [159]
        )
      spids: [155 158]
    )
    (FuncDef
      name: check
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (SimpleCommand
                  words: [{(echo)} {(DQ ($ VSub_Number '$1'))}]
                  redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expect)} spids:[219])]
                )
                (AndOr
                  children: [
                    (Subshell
                      child: 
                        (AndOr
                          children: [
                            (C {(cd)} {(fetch)})
                            (C {(git)} {(log)} {(-1)} {(--format) (Lit_Other '=') (Lit_Other '%') (s)} 
                              {(FETCH_HEAD)}
                            )
                          ]
                          op_id: Op_DAmp
                        )
                      redirects: [
                        (Redir
                          op_id: Redir_Great
                          fd: -1
                          arg_word: {(actual.fetch)}
                          spids: [246]
                        )
                      ]
                      spids: [225 244]
                    )
                    (AndOr
                      children: [
                        (Subshell
                          child: 
                            (AndOr
                              children: [
                                (C {(cd)} {(clone)})
                                (C {(git)} {(log)} {(-1)} 
                                  {(--format) (Lit_Other '=') (Lit_Other '%') (s)} {(HEAD)}
                                )
                              ]
                              op_id: Op_DAmp
                            )
                          redirects: [
                            (Redir
                              op_id: Redir_Great
                              fd: -1
                              arg_word: {(actual.clone)}
                              spids: [273]
                            )
                          ]
                          spids: [252 271]
                        )
                        (AndOr
                          children: [
                            (C {(test_cmp)} {(expect)} {(actual.fetch)})
                            (C {(test_cmp)} {(expect)} {(actual.clone)})
                          ]
                          op_id: Op_DAmp
                        )
                      ]
                      op_id: Op_DAmp
                    )
                  ]
                  op_id: Op_DAmp
                )
              ]
              op_id: Op_DAmp
            )
          ]
          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)})
  ]
)