(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: 
            {
              (SQ <'Two way merge with read-tree -m -u $H $M\n'> <'\n'> 
                <'This is identical to t1001, but uses -u to update the work tree as well.\n'> <'\n'>
              )
            }
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (C {<.>} {(DQ ($ Id.VSub_DollarName '$TEST_DIRECTORY')) <'/lib-read-tree.sh'>})
    (command.ShFunction
      name: compare_change
      body: 
        (BraceGroup
          children: [
            (command.Simple
              words: [
                {<sed>}
                {<-e>}
                {(SQ <'1{/^diff --git /d;}'>)}
                {<-e>}
                {(SQ <'2{/^index /d;}'>)}
                {<-e>}
                {(SQ <'/^--- /d; /^+++ /d; /^@@ /d;'>)}
                {<-e>}
                {(SQ <'s/^\\(.[0-7][0-7][0-7][0-7][0-7][0-7]\\) '>) 
                  (DQ ($ Id.VSub_DollarName '$_x40')) (SQ <' /\\1 X /'>)
                }
                {(DQ ($ Id.VSub_Number '$1'))}
              ]
              redirects: [(redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<current>})]
              do_fork: T
            )
            (C {<test_cmp>} {<expected>} {<current>})
          ]
        )
    )
    (command.ShFunction
      name: check_cache_at
      body: 
        (BraceGroup
          children: [
            (command.ShAssignment
              pairs: [
                (assign_pair
                  lhs: (sh_lhs_expr.Name name:clean_if_empty)
                  op: assign_op.Equal
                  rhs: 
                    {
                      (command_sub
                        left_token: <Id.Left_DollarParen '$('>
                        child: (C {<git>} {<diff-files>} {<-->} {(DQ ($ Id.VSub_Number '$1'))})
                      )
                    }
                  spids: [106]
                )
              ]
            )
            (command.Case
              to_match: {(DQ ($ Id.VSub_DollarName '$clean_if_empty'))}
              arms: [
                (case_arm
                  pat_list: [{(SQ )}]
                  action: [(C {<echo>} {(DQ ($ Id.VSub_Number '$1') <': clean'>)})]
                  spids: [129 131 140 -1]
                )
                (case_arm
                  pat_list: [{<Id.Lit_QMark '?'> <Id.Lit_Star '*'>}]
                  action: [(C {<echo>} {(DQ ($ Id.VSub_Number '$1') <': dirty'>)})]
                  spids: [143 145 154 -1]
                )
              ]
            )
            (command.Case
              to_match: {(DQ ($ Id.VSub_Number '$2') <','> ($ Id.VSub_DollarName '$clean_if_empty'))}
              arms: [
                (case_arm
                  pat_list: [{<clean> <Id.Lit_Comma ','>}]
                  action: [(C {<Id.Lit_Colon ':'>})]
                  spids: [171 173 177 -1]
                )
                (case_arm
                  pat_list: [{<clean> <Id.Lit_Comma ','> <Id.Lit_QMark '?'> <Id.Lit_Star '*'>}]
                  action: [(C {<false>})]
                  spids: [180 184 188 -1]
                )
                (case_arm
                  pat_list: [{<dirty> <Id.Lit_Comma ','>}]
                  action: [(C {<false>})]
                  spids: [191 193 197 -1]
                )
                (case_arm
                  pat_list: [{<dirty> <Id.Lit_Comma ','> <Id.Lit_QMark '?'> <Id.Lit_Star '*'>}]
                  action: [(C {<Id.Lit_Colon ':'>})]
                  spids: [200 204 208 -1]
                )
              ]
            )
          ]
        )
    )
    (C {<test_expect_success>} {<setup>} 
      {
        (SQ <'echo frotz >frotz &&\n'> <'     echo nitfol >nitfol &&\n'> 
          <'     echo bozbar >bozbar &&\n'> <'     echo rezrov >rezrov &&\n'> <'     git update-index --add nitfol bozbar rezrov &&\n'> 
          <'     treeH=$(git write-tree) &&\n'> <'     echo treeH $treeH &&\n'> <'     git ls-tree $treeH &&\n'> <'\n'> 
          <'     echo gnusto >bozbar &&\n'> <'     git update-index --add frotz bozbar --force-remove rezrov &&\n'> 
          <'     git ls-files --stage >M.out &&\n'> <'     treeM=$(git write-tree) &&\n'> <'     echo treeM $treeM &&\n'> <'     git ls-tree $treeM &&\n'> 
          <'     sum bozbar frotz nitfol >M.sum &&\n'> <'     git diff-tree $treeH $treeM'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'1, 2, 3 - no carry forward'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >1-3.out &&\n'> 
          <'     cmp M.out 1-3.out &&\n'> <'     sum bozbar frotz nitfol >actual3.sum &&\n'> <'     cmp M.sum actual3.sum &&\n'> 
          <'     check_cache_at bozbar clean &&\n'> <'     check_cache_at frotz clean &&\n'> <'     check_cache_at nitfol clean'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'4 - carry forward local addition.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo "+100644 X 0\tyomin" >expected &&\n'> <'     echo yomin >yomin &&\n'> 
          <'     git update-index --add yomin &&\n'> <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >4.out &&\n'> 
          <'     test_might_fail git diff -U0 --no-index M.out 4.out >4diff.out &&\n'> <'     compare_change 4diff.out expected &&\n'> <'     check_cache_at yomin clean &&\n'> 
          <'     sum bozbar frotz nitfol >actual4.sum &&\n'> <'     cmp M.sum actual4.sum &&\n'> <'     echo yomin >yomin1 &&\n'> <'     diff yomin yomin1 &&\n'> 
          <'     rm -f yomin1'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'5 - carry forward local addition.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     read_tree_u_must_succeed -m -u $treeH &&\n'> <'     echo yomin >yomin &&\n'> 
          <'     git update-index --add yomin &&\n'> <'     echo yomin yomin >yomin &&\n'> <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> 
          <'     git ls-files --stage >5.out &&\n'> <'     test_might_fail git diff -U0 --no-index M.out 5.out >5diff.out &&\n'> 
          <'     compare_change 5diff.out expected &&\n'> <'     check_cache_at yomin dirty &&\n'> <'     sum bozbar frotz nitfol >actual5.sum &&\n'> 
          <'     cmp M.sum actual5.sum &&\n'> <'     : dirty index should have prevented -u from checking it out. &&\n'> 
          <'     echo yomin yomin >yomin1 &&\n'> <'     diff yomin yomin1 &&\n'> <'     rm -f yomin1'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'6 - local addition already has the same.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo frotz >frotz &&\n'> <'     git update-index --add frotz &&\n'> 
          <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >6.out &&\n'> <'     test_cmp M.out 6.out &&\n'> 
          <'     check_cache_at frotz clean &&\n'> <'     sum bozbar frotz nitfol >actual3.sum &&\n'> <'     cmp M.sum actual3.sum &&\n'> 
          <'     echo frotz >frotz1 &&\n'> <'     diff frotz frotz1 &&\n'> <'     rm -f frotz1'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'7 - local addition already has the same.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo frotz >frotz &&\n'> <'     git update-index --add frotz &&\n'> 
          <'     echo frotz frotz >frotz &&\n'> <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >7.out &&\n'> 
          <'     test_cmp M.out 7.out &&\n'> <'     check_cache_at frotz dirty &&\n'> <'     sum bozbar frotz nitfol >actual7.sum &&\n'> 
          <'     if cmp M.sum actual7.sum; then false; else :; fi &&\n'> <'     : dirty index should have prevented -u from checking it out. &&\n'> 
          <'     echo frotz frotz >frotz1 &&\n'> <'     diff frotz frotz1 &&\n'> <'     rm -f frotz1'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'8 - conflicting addition.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo frotz frotz >frotz &&\n'> <'     git update-index --add frotz &&\n'> 
          <'     if read_tree_u_must_succeed -m -u $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'9 - conflicting addition.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo frotz frotz >frotz &&\n'> <'     git update-index --add frotz &&\n'> 
          <'     echo frotz >frotz &&\n'> <'     if read_tree_u_must_succeed -m -u $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'10 - path removed.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo rezrov >rezrov &&\n'> <'     git update-index --add rezrov &&\n'> 
          <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >10.out &&\n'> <'     cmp M.out 10.out &&\n'> 
          <'     sum bozbar frotz nitfol >actual10.sum &&\n'> <'     cmp M.sum actual10.sum'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'11 - dirty path removed.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo rezrov >rezrov &&\n'> <'     git update-index --add rezrov &&\n'> 
          <'     echo rezrov rezrov >rezrov &&\n'> <'     if read_tree_u_must_succeed -m -u $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'12 - unmatching local changes being removed.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo rezrov rezrov >rezrov &&\n'> <'     git update-index --add rezrov &&\n'> 
          <'     if read_tree_u_must_succeed -m -u $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'13 - unmatching local changes being removed.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo rezrov rezrov >rezrov &&\n'> <'     git update-index --add rezrov &&\n'> 
          <'     echo rezrov >rezrov &&\n'> <'     if read_tree_u_must_succeed -m -u $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expected>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.HereDoc
              here_begin: {<EOF>}
              here_end_span_id: 517
              stdin_parts: [<'-100644 X 0\tnitfol\n'> <'+100644 X 0\tnitfol\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'14 - unchanged in two heads.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo nitfol nitfol >nitfol &&\n'> <'     git update-index --add nitfol &&\n'> 
          <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >14.out &&\n'> 
          <'     test_must_fail git diff -U0 --no-index M.out 14.out >14diff.out &&\n'> <'     compare_change 14diff.out expected &&\n'> <'     sum bozbar frotz >actual14.sum &&\n'> 
          <'     grep -v nitfol M.sum > expected14.sum &&\n'> <'     cmp expected14.sum actual14.sum &&\n'> <'     sum bozbar frotz nitfol >actual14a.sum &&\n'> 
          <'     if cmp M.sum actual14a.sum; then false; else :; fi &&\n'> <'     check_cache_at nitfol clean &&\n'> <'     echo nitfol nitfol >nitfol1 &&\n'> 
          <'     diff nitfol nitfol1 &&\n'> <'     rm -f nitfol1'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'15 - unchanged in two heads.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo nitfol nitfol >nitfol &&\n'> <'     git update-index --add nitfol &&\n'> 
          <'     echo nitfol nitfol nitfol >nitfol &&\n'> <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >15.out &&\n'> 
          <'     test_must_fail git diff -U0 --no-index M.out 15.out >15diff.out &&\n'> <'     compare_change 15diff.out expected &&\n'> <'     check_cache_at nitfol dirty &&\n'> 
          <'     sum bozbar frotz >actual15.sum &&\n'> <'     grep -v nitfol M.sum > expected15.sum &&\n'> <'     cmp expected15.sum actual15.sum &&\n'> 
          <'     sum bozbar frotz nitfol >actual15a.sum &&\n'> <'     if cmp M.sum actual15a.sum; then false; else :; fi &&\n'> 
          <'     echo nitfol nitfol nitfol >nitfol1 &&\n'> <'     diff nitfol nitfol1 &&\n'> <'     rm -f nitfol1'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'16 - conflicting local change.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo bozbar bozbar >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     if read_tree_u_must_succeed -m -u $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'17 - conflicting local change.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo bozbar bozbar >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     echo bozbar bozbar bozbar >bozbar &&\n'> <'     if read_tree_u_must_succeed -m -u $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'18 - local change already having a good result.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo gnusto >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >18.out &&\n'> <'     test_cmp M.out 18.out &&\n'> 
          <'     check_cache_at bozbar clean &&\n'> <'     sum bozbar frotz nitfol >actual18.sum &&\n'> <'     cmp M.sum actual18.sum'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'19 - local change already having a good result, further modified.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo gnusto >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     echo gnusto gnusto >bozbar &&\n'> <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >19.out &&\n'> 
          <'     test_cmp M.out 19.out &&\n'> <'     check_cache_at bozbar dirty &&\n'> <'     sum frotz nitfol >actual19.sum &&\n'> 
          <'     grep -v bozbar  M.sum > expected19.sum &&\n'> <'     cmp expected19.sum actual19.sum &&\n'> <'     sum bozbar frotz nitfol >actual19a.sum &&\n'> 
          <'     if cmp M.sum actual19a.sum; then false; else :; fi &&\n'> <'     echo gnusto gnusto >bozbar1 &&\n'> <'     diff bozbar bozbar1 &&\n'> <'     rm -f bozbar1'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'20 - no local change, use new tree.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo bozbar >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     read_tree_u_must_succeed -m -u $treeH $treeM &&\n'> <'     git ls-files --stage >20.out &&\n'> <'     test_cmp M.out 20.out &&\n'> 
          <'     check_cache_at bozbar clean &&\n'> <'     sum bozbar frotz nitfol >actual20.sum &&\n'> <'     cmp M.sum actual20.sum'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'21 - no local change, dirty cache.'>)} 
      {
        (SQ <'rm -f .git/index nitfol bozbar rezrov frotz &&\n'> 
          <'     read_tree_u_must_succeed --reset -u $treeH &&\n'> <'     echo bozbar >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     echo gnusto gnusto >bozbar &&\n'> <'     if read_tree_u_must_succeed -m -u $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'DF vs DF/DF case setup.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     echo DF >DF &&\n'> <'     git update-index --add DF &&\n'> 
          <'     treeDF=$(git write-tree) &&\n'> <'     echo treeDF $treeDF &&\n'> <'     git ls-tree $treeDF &&\n'> <'\n'> <'     rm -f DF &&\n'> 
          <'     mkdir DF &&\n'> <'     echo DF/DF >DF/DF &&\n'> <'     git update-index --add --remove DF DF/DF &&\n'> 
          <'     treeDFDF=$(git write-tree) &&\n'> <'     echo treeDFDF $treeDFDF &&\n'> <'     git ls-tree $treeDFDF &&\n'> 
          <'     git ls-files --stage >DFDF.out'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'DF vs DF/DF case test.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     rm -fr DF &&\n'> <'     echo DF >DF &&\n'> 
          <'     git update-index --add DF &&\n'> <'     read_tree_u_must_succeed -m -u $treeDF $treeDFDF &&\n'> 
          <'     git ls-files --stage >DFDFcheck.out &&\n'> <'     test_cmp DFDF.out DFDFcheck.out &&\n'> <'     check_cache_at DF/DF clean'>
        )
      }
    )
    (C {<test_done>})
  ]
)