(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'read-tree D/F conflict corner cases'>)}
          spids: [4]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (C {<.>} {(DQ ($ Id.VSub_DollarName '$TEST_DIRECTORY')) <'/lib-read-tree.sh'>})
    (command.ShFunction
      name: maketree
      body: 
        (BraceGroup
          children: [
            (command.Subshell
              child: 
                (command.AndOr
                  ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
                  children: [
                    (C {<rm>} {<-f>} {<'.git/index'>} {<'.git/index.lock'>})
                    (C {<git>} {<clean>} {<-d>} {<-f>} {<-f>} {<-q>} {<-x>})
                    (command.ShAssignment
                      pairs: [
                        (assign_pair
                          lhs: (sh_lhs_expr.Name name:name)
                          op: assign_op.Equal
                          rhs: {(DQ ($ Id.VSub_Number '$1'))}
                          spids: [61]
                        )
                      ]
                    )
                    (C {<shift>})
                    (command.ForEach
                      iter_name: it
                      do_arg_iter: T
                      body: 
                        (command.DoGroup
                          children: [
                            (command.AndOr
                              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DPipe]
                              children: [
                                (command.ShAssignment
                                  pairs: [
                                    (assign_pair
                                      lhs: (sh_lhs_expr.Name name:path)
                                      op: assign_op.Equal
                                      rhs: 
                                        {
                                          (command_sub
                                            left_token: <Id.Left_DollarParen '$('>
                                            child: 
                                              (C {<expr>} {(DQ ($ Id.VSub_DollarName '$it'))} 
                                                {<Id.Lit_Colon ':'>} {(SQ <'\\([^:]*\\)'>)}
                                              )
                                          )
                                        }
                                      spids: [82]
                                    )
                                  ]
                                )
                                (C {<mkdir>} {<-p>} 
                                  {
                                    (command_sub
                                      left_token: <Id.Left_DollarParen '$('>
                                      child: (C {<dirname>} {(DQ ($ Id.VSub_DollarName '$path'))})
                                    )
                                  }
                                )
                                (command.Simple
                                  words: [{<echo>} {(DQ ($ Id.VSub_DollarName '$it'))}]
                                  redirects: [
                                    (redir
                                      op: <Id.Redir_Great '>'>
                                      loc: (redir_loc.Fd fd:1)
                                      arg: {(DQ ($ Id.VSub_DollarName '$path'))}
                                    )
                                  ]
                                  do_fork: T
                                )
                                (C {<git>} {<update-index>} {<--add>} 
                                  {(DQ ($ Id.VSub_DollarName '$path'))}
                                )
                                (command.ControlFlow
                                  token: <Id.ControlFlow_Exit exit>
                                )
                              ]
                            )
                          ]
                        )
                    )
                    (C {<git>} {<tag>} {(DQ ($ Id.VSub_DollarName '$name'))} 
                      {
                        (command_sub
                          left_token: <Id.Left_DollarParen '$('>
                          child: (C {<git>} {<write-tree>})
                        )
                      }
                    )
                  ]
                )
            )
          ]
        )
    )
    (command.ShFunction
      name: settree
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp Id.Op_DAmp]
              children: [
                (C {<rm>} {<-f>} {<'.git/index'>} {<'.git/index.lock'>})
                (C {<git>} {<clean>} {<-d>} {<-f>} {<-f>} {<-q>} {<-x>})
                (C {<git>} {<read-tree>} {(DQ ($ Id.VSub_Number '$1'))})
                (C {<git>} {<checkout-index>} {<-f>} {<-q>} {<-u>} {<-a>})
                (C {<git>} {<update-index>} {<--refresh>})
              ]
            )
          ]
        )
    )
    (command.ShFunction
      name: checkindex
      body: 
        (BraceGroup
          children: [
            (command.AndOr
              ops: [Id.Op_DAmp Id.Op_DAmp]
              children: [
                (command.Pipeline
                  children: [
                    (C {<git>} {<ls-files>} {<-s>})
                    (command.Simple
                      words: [
                        {<sed>}
                        {
                          (DQ <'s|^[0-7][0-7]* '> ($ Id.VSub_DollarName '$_x40') <' '> 
                            <Id.Lit_BadBackslash '\\'> <'([0-3]'> <Id.Lit_BadBackslash '\\'> <')\t|'> <Id.Lit_BadBackslash '\\'> <'1 |'>
                          )
                        }
                      ]
                      redirects: [
                        (redir
                          op: <Id.Redir_Great '>'>
                          loc: (redir_loc.Fd fd:1)
                          arg: {<current>}
                        )
                      ]
                      do_fork: T
                    )
                  ]
                  negated: F
                )
                (command.Simple
                  words: [{<cat>}]
                  redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})]
                  do_fork: T
                )
                (C {<test_cmp>} {<expect>} {<current>})
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {<setup>} 
      {
        (SQ <'\n'> <'\tmaketree O-000 a/b-2/c/d a/b/c/d a/x &&\n'> 
          <'\tmaketree A-000 a/b-2/c/d a/b/c/d a/x &&\n'> <'\tmaketree A-001 a/b-2/c/d a/b/c/d a/b/c/e a/x &&\n'> 
          <'\tmaketree B-000 a/b-2/c/d a/b     a/x &&\n'> <'\n'> <'\tmaketree O-010 t-0     t/1  t/2 t=3 &&\n'> <'\tmaketree A-010 t-0 t            t=3 &&\n'> 
          <'\tmaketree B-010         t/1:     t=3: &&\n'> <'\n'> <'\tmaketree O-020 ds/dma/ioat.c ds/dma/ioat_dca.c &&\n'> 
          <'\tmaketree A-020 ds/dma/ioat/Makefile ds/dma/ioat/registers.h &&\n'> <'\t:\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'3-way (1)'>)} 
      {
        (SQ <'\n'> <'\tsettree A-000 &&\n'> <'\tread_tree_u_must_succeed -m -u O-000 A-000 B-000 &&\n'> 
          <'\tcheckindex <<-EOF\n'> <'\t3 a/b\n'> <'\t0 a/b-2/c/d\n'> <'\t1 a/b/c/d\n'> <'\t2 a/b/c/d\n'> <'\t0 a/x\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'3-way (2)'>)} 
      {
        (SQ <'\n'> <'\tsettree A-001 &&\n'> <'\tread_tree_u_must_succeed -m -u O-000 A-001 B-000 &&\n'> 
          <'\tcheckindex <<-EOF\n'> <'\t3 a/b\n'> <'\t0 a/b-2/c/d\n'> <'\t1 a/b/c/d\n'> <'\t2 a/b/c/d\n'> <'\t2 a/b/c/e\n'> <'\t0 a/x\n'> 
          <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'3-way (3)'>)} 
      {
        (SQ <'\n'> <'\tsettree A-010 &&\n'> <'\tread_tree_u_must_succeed -m -u O-010 A-010 B-010 &&\n'> 
          <'\tcheckindex <<-EOF\n'> <'\t2 t\n'> <'\t1 t-0\n'> <'\t2 t-0\n'> <'\t1 t/1\n'> <'\t3 t/1\n'> <'\t1 t/2\n'> <'\t0 t=3\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'2-way (1)'>)} 
      {
        (SQ <'\n'> <'\tsettree O-020 &&\n'> <'\tread_tree_u_must_succeed -m -u O-020 A-020 &&\n'> 
          <'\tcheckindex <<-EOF\n'> <'\t0 ds/dma/ioat/Makefile\n'> <'\t0 ds/dma/ioat/registers.h\n'> <'\tEOF\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)