(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: 
            {
              (SQ <'Two way merge with read-tree -m $H $M\n'> <'\n'> 
                <'This test tries two-way merge (aka fast-forward with carry forward).\n'> <'\n'> <'There is the head (called H) and another commit (called M), which is\n'> 
                <'simply ahead of H.  The index and the work tree contains a state that\n'> <'is derived from H, but may also have local changes.  This test checks\n'> 
                <'all the combinations described in the two-tree merge "carry forward"\n'> <'rules, found in <Documentation/git read-tree.txt>.\n'> <'\n'> 
                <'In the test, these paths are used:\n'> <'        bozbar  - in H, stays in M, modified from bozbar to gnusto\n'> 
                <'        frotz   - not in H added in M\n'> <'        nitfol  - in H, stays in M unmodified\n'> <'        rezrov  - in H, deleted in M\n'> 
                <'\tyomin   - not in H or M\n'>
              )
            }
          spids: [13]
        )
      ]
      spids: [13]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(.)} {(DQ ($ VSub_Name '$TEST_DIRECTORY')) (/lib-read-tree.sh)})
    (FuncDef
      name: read_tree_twoway
      body: 
        (BraceGroup
          children: [
            (AndOr
              children: [
                (C {(git)} {(read-tree)} {(-m)} {(DQ ($ VSub_Number '$1'))} {(DQ ($ VSub_Number '$2'))})
                (C {(git)} {(ls-files)} {(--stage)})
              ]
              op_id: Op_DAmp
            )
          ]
          spids: [50]
        )
      spids: [45 49]
    )
    (FuncDef
      name: compare_change
      body: 
        (BraceGroup
          children: [
            (SimpleCommand
              words: [
                {(sed)}
                {(-n)}
                {(-e)}
                {(SQ <'/^--- /d; /^+++ /d; /^@@ /d;'>)}
                {(-e)}
                {(SQ <'s/^\\([-+][0-7][0-7][0-7][0-7][0-7][0-7]\\) '>) (DQ ($ VSub_Name '$_x40')) 
                  (SQ <' /\\1 X /p'>)
                }
                {(DQ ($ VSub_Number '$1'))}
              ]
              redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(current)} spids:[90])]
            )
            (C {(test_cmp)} {(expected)} {(current)})
          ]
          spids: [83]
        )
      spids: [78 82]
    )
    (FuncDef
      name: check_cache_at
      body: 
        (BraceGroup
          children: [
            (Assignment
              keyword: Assign_None
              pairs: [
                (assign_pair
                  lhs: (LhsName name:clean_if_empty)
                  op: Equal
                  rhs: 
                    {
                      (CommandSubPart
                        command_list: 
                          (CommandList
                            children: [(C {(git)} {(diff-files)} {(--)} {(DQ ($ VSub_Number '$1'))})]
                          )
                        left_token: <Left_CommandSub '$('>
                        spids: [140 150]
                      )
                    }
                  spids: [139]
                )
              ]
              spids: [139]
            )
            (Case
              to_match: {(DQ ($ VSub_Name '$clean_if_empty'))}
              arms: [
                (case_arm
                  pat_list: [{(SQ )}]
                  action: [(C {(echo)} {(DQ ($ VSub_Number '$1') (': clean'))})]
                  spids: [-1 164 173 -1]
                )
                (case_arm
                  pat_list: [{(Lit_Other '?') (Lit_Other '*')}]
                  action: [(C {(echo)} {(DQ ($ VSub_Number '$1') (': dirty'))})]
                  spids: [176 178 187 -1]
                )
              ]
              spids: [153 159 190]
            )
            (Case
              to_match: {(DQ ($ VSub_Number '$2') (',') ($ VSub_Name '$clean_if_empty'))}
              arms: [
                (case_arm
                  pat_list: [{(clean) (Lit_Comma ',')}]
                  action: [(C {(Lit_Other ':')})]
                  spids: [204 206 210 -1]
                )
                (case_arm
                  pat_list: [{(clean) (Lit_Comma ',') (Lit_Other '?') (Lit_Other '*')}]
                  action: [(C {(false)})]
                  spids: [213 217 221 -1]
                )
                (case_arm
                  pat_list: [{(dirty) (Lit_Comma ',')}]
                  action: [(C {(false)})]
                  spids: [224 226 230 -1]
                )
                (case_arm
                  pat_list: [{(dirty) (Lit_Comma ',') (Lit_Other '?') (Lit_Other '*')}]
                  action: [(C {(Lit_Other ':')})]
                  spids: [233 237 241 -1]
                )
              ]
              spids: [193 201 244]
            )
          ]
          spids: [136]
        )
      spids: [131 135]
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(bozbar-old)} spids:[251])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: 
            {('This is a sample file used in two-way fast-forward merge\n') 
              ('tests.  Its second line ends with a magic word bozbar\n') ('which will be modified by the merged head to gnusto.\n') 
              ('It has some extra lines so that external tools can\n') ('successfully merge independent changes made to later\n') 
              ('lines (such as this one), avoiding line conflicts.\n')
            }
          do_expansion: False
          here_end: EOF
          was_filled: True
          spids: [254]
        )
      ]
    )
    (SimpleCommand
      words: [{(sed)} {(-e)} {(SQ <'s/bozbar/gnusto (earlier bozbar)/'>)} {(bozbar-old)}]
      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(bozbar-new)} spids:[269])]
    )
    (C {(test_expect_success)} {(setup)} 
      {
        (SQ <'echo frotz >frotz &&\n'> <'     echo nitfol >nitfol &&\n'> 
          <'     cat bozbar-old >bozbar &&\n'> <'     echo rezrov >rezrov &&\n'> <'     echo yomin >yomin &&\n'> 
          <'     git update-index --add nitfol bozbar rezrov &&\n'> <'     treeH=$(git write-tree) &&\n'> <'     echo treeH $treeH &&\n'> <'     git ls-tree $treeH &&\n'> 
          <'\n'> <'     cat bozbar-new >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'> <'     git diff-tree $treeH $treeM'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'1, 2, 3 - no carry forward'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_twoway $treeH $treeM &&\n'> 
          <'     git ls-files --stage >1-3.out &&\n'> <'     test_cmp M.out 1-3.out &&\n'> <'     check_cache_at bozbar dirty &&\n'> 
          <'     check_cache_at frotz dirty &&\n'> <'     check_cache_at nitfol dirty'>
        )
      }
    )
    (SimpleCommand
      words: [{(echo)} {(SQ <'+100644 X 0\tyomin'>)}]
      redirects: [(Redir op_id:Redir_Great fd:-1 arg_word:{(expected)} spids:[329])]
    )
    (C {(test_expect_success)} {(SQ <'4 - carry forward local addition.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     git update-index --add yomin &&\n'> <'     read_tree_twoway $treeH $treeM &&\n'> 
          <'     git ls-files --stage >4.out &&\n'> <'     test_must_fail git diff --no-index M.out 4.out >4diff.out &&\n'> 
          <'     compare_change 4diff.out expected &&\n'> <'     check_cache_at yomin clean'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'5 - carry forward local addition.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo yomin >yomin &&\n'> <'     git update-index --add yomin &&\n'> 
          <'     echo yomin yomin >yomin &&\n'> <'     read_tree_twoway $treeH $treeM &&\n'> <'     git ls-files --stage >5.out &&\n'> 
          <'     test_must_fail git diff --no-index M.out 5.out >5diff.out &&\n'> <'     compare_change 5diff.out expected &&\n'> <'     check_cache_at yomin dirty'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'6 - local addition already has the same.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     git update-index --add frotz &&\n'> <'     read_tree_twoway $treeH $treeM &&\n'> 
          <'     git ls-files --stage >6.out &&\n'> <'     test_cmp M.out 6.out &&\n'> <'     check_cache_at frotz clean'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'7 - local addition already has the same.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo frotz >frotz &&\n'> <'     git update-index --add frotz &&\n'> 
          <'     echo frotz frotz >frotz &&\n'> <'     read_tree_twoway $treeH $treeM &&\n'> <'     git ls-files --stage >7.out &&\n'> 
          <'     test_cmp M.out 7.out &&\n'> <'     check_cache_at frotz dirty'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'8 - conflicting addition.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo frotz frotz >frotz &&\n'> <'     git update-index --add frotz &&\n'> 
          <'     if read_tree_twoway $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'9 - conflicting addition.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo frotz frotz >frotz &&\n'> <'     git update-index --add frotz &&\n'> 
          <'     echo frotz >frotz &&\n'> <'     if read_tree_twoway $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'10 - path removed.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo rezrov >rezrov &&\n'> <'     git update-index --add rezrov &&\n'> 
          <'     read_tree_twoway $treeH $treeM &&\n'> <'     git ls-files --stage >10.out &&\n'> <'     test_cmp M.out 10.out'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'11 - dirty path removed.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo rezrov >rezrov &&\n'> <'     git update-index --add rezrov &&\n'> 
          <'     echo rezrov rezrov >rezrov &&\n'> <'     if read_tree_twoway $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'12 - unmatching local changes being removed.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo rezrov rezrov >rezrov &&\n'> <'     git update-index --add rezrov &&\n'> 
          <'     if read_tree_twoway $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'13 - unmatching local changes being removed.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo rezrov rezrov >rezrov &&\n'> <'     git update-index --add rezrov &&\n'> 
          <'     echo rezrov >rezrov &&\n'> <'     if read_tree_twoway $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (SimpleCommand
      words: [{(cat)}]
      redirects: [
        (Redir op_id:Redir_Great fd:-1 arg_word:{(expected)} spids:[554])
        (HereDoc
          op_id: Redir_DLess
          fd: -1
          body: {(DQ ('-100644 X 0\tnitfol\n') ('+100644 X 0\tnitfol\n'))}
          do_expansion: True
          here_end: EOF
          was_filled: True
          spids: [557]
        )
      ]
    )
    (C {(test_expect_success)} {(SQ <'14 - unchanged in two heads.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo nitfol nitfol >nitfol &&\n'> <'     git update-index --add nitfol &&\n'> 
          <'     read_tree_twoway $treeH $treeM &&\n'> <'     git ls-files --stage >14.out &&\n'> 
          <'     test_must_fail git diff --no-index M.out 14.out >14diff.out &&\n'> <'     compare_change 14diff.out expected &&\n'> <'     check_cache_at nitfol clean'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'15 - unchanged in two heads.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo nitfol nitfol >nitfol &&\n'> <'     git update-index --add nitfol &&\n'> 
          <'     echo nitfol nitfol nitfol >nitfol &&\n'> <'     read_tree_twoway $treeH $treeM &&\n'> <'     git ls-files --stage >15.out &&\n'> 
          <'     test_must_fail git diff --no-index M.out 15.out >15diff.out &&\n'> <'     compare_change 15diff.out expected &&\n'> <'     check_cache_at nitfol dirty'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'16 - conflicting local change.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo bozbar bozbar >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     if read_tree_twoway $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'17 - conflicting local change.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     echo bozbar bozbar >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     echo bozbar bozbar bozbar >bozbar &&\n'> <'     if read_tree_twoway $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'18 - local change already having a good result.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     cat bozbar-new >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     read_tree_twoway $treeH $treeM &&\n'> <'     git ls-files --stage >18.out &&\n'> <'     test_cmp M.out 18.out &&\n'> 
          <'     check_cache_at bozbar clean'>
        )
      }
    )
    (C {(test_expect_success)} 
      {(SQ <'19 - local change already having a good result, further modified.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     cat bozbar-new >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     echo gnusto gnusto >bozbar &&\n'> <'     read_tree_twoway $treeH $treeM &&\n'> <'     git ls-files --stage >19.out &&\n'> 
          <'     test_cmp M.out 19.out &&\n'> <'     check_cache_at bozbar dirty'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'20 - no local change, use new tree.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     cat bozbar-old >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     read_tree_twoway $treeH $treeM &&\n'> <'     git ls-files --stage >20.out &&\n'> <'     test_cmp M.out 20.out &&\n'> 
          <'     check_cache_at bozbar dirty'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'21 - no local change, dirty cache.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     cat bozbar-old >bozbar &&\n'> <'     git update-index --add bozbar &&\n'> 
          <'     echo gnusto gnusto >bozbar &&\n'> <'     if read_tree_twoway $treeH $treeM; then false; else :; fi'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'22 - local change cache updated.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     read_tree_must_succeed $treeH &&\n'> 
          <'     git checkout-index -u -f -q -a &&\n'> <'     sed -e "s/such as/SUCH AS/" bozbar-old >bozbar &&\n'> 
          <'     git update-index --add bozbar &&\n'> <'     if read_tree_twoway $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_twoway $treeDF $treeDFDF &&\n'> <'     git ls-files --stage >DFDFcheck.out &&\n'> 
          <'     test_cmp DFDF.out DFDFcheck.out &&\n'> <'     check_cache_at DF/DF dirty &&\n'> <'     :'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'a/b (untracked) vs a case setup.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     : >a &&\n'> <'     git update-index --add a &&\n'> 
          <'     treeM=$(git write-tree) &&\n'> <'     echo treeM $treeM &&\n'> <'     git ls-tree $treeM &&\n'> 
          <'     git ls-files --stage >treeM.out &&\n'> <'\n'> <'     rm -f a &&\n'> <'     git update-index --remove a &&\n'> <'     mkdir a &&\n'> 
          <'     : >a/b &&\n'> <'     treeH=$(git write-tree) &&\n'> <'     echo treeH $treeH &&\n'> <'     git ls-tree $treeH'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'a/b (untracked) vs a, plus c/d case test.'>)} 
      {
        (SQ <'read_tree_u_must_fail -u -m "$treeH" "$treeM" &&\n'> <'     git ls-files --stage &&\n'> 
          <'     test -f a/b'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'a/b vs a, plus c/d case setup.'>)} 
      {
        (SQ <'rm -f .git/index &&\n'> <'     rm -fr a &&\n'> <'     : >a &&\n'> <'     mkdir c &&\n'> 
          <'     : >c/d &&\n'> <'     git update-index --add a c/d &&\n'> <'     treeM=$(git write-tree) &&\n'> 
          <'     echo treeM $treeM &&\n'> <'     git ls-tree $treeM &&\n'> <'     git ls-files --stage >treeM.out &&\n'> <'\n'> 
          <'     rm -f a &&\n'> <'     mkdir a &&\n'> <'     : >a/b &&\n'> <'     git update-index --add --remove a a/b &&\n'> 
          <'     treeH=$(git write-tree) &&\n'> <'     echo treeH $treeH &&\n'> <'     git ls-tree $treeH'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'a/b vs a, plus c/d case test.'>)} 
      {
        (SQ <'read_tree_u_must_succeed -u -m "$treeH" "$treeM" &&\n'> 
          <'     git ls-files --stage | tee >treeMcheck.out &&\n'> <'     test_cmp treeM.out treeMcheck.out'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'-m references the correct modified tree'>)} 
      {
        (SQ <'\n'> <'\techo >file-a &&\n'> <'\techo >file-b &&\n'> <'\tgit add file-a file-b &&\n'> 
          <'\tgit commit -a -m "test for correct modified tree" &&\n'> <'\tgit branch initial-mod &&\n'> <'\techo b >file-b &&\n'> <'\tgit commit -a -m "B" &&\n'> 
          <'\techo a >file-a &&\n'> <'\tgit add file-a &&\n'> <'\tgit ls-tree $(git write-tree) file-a >expect &&\n'> 
          <'\tread_tree_must_succeed -m HEAD initial-mod &&\n'> <'\tgit ls-tree $(git write-tree) file-a >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)