(CommandList
  children: [
    (Assignment
      keyword: Assign_None
      pairs: [
        (assign_pair
          lhs: (LhsName name:test_description)
          op: Equal
          rhs: {(SQ <'merge-recursive backend test'>)}
          spids: [4]
        )
      ]
      spids: [4]
    )
    (C {(.)} {(./test-lib.sh)})
    (C {(test_expect_success)} {(SQ <'setup 1'>)} 
      {
        (SQ <'\n'> <'\n'> <'\techo hello >a &&\n'> <'\to0=$(git hash-object a) &&\n'> <'\tcp a b &&\n'> 
          <'\tcp a c &&\n'> <'\tmkdir d &&\n'> <'\tcp a d/e &&\n'> <'\n'> <'\ttest_tick &&\n'> <'\tgit add a b c d/e &&\n'> 
          <'\tgit commit -m initial &&\n'> <'\tc0=$(git rev-parse --verify HEAD) &&\n'> <'\tgit branch side &&\n'> <'\tgit branch df-1 &&\n'> 
          <'\tgit branch df-2 &&\n'> <'\tgit branch df-3 &&\n'> <'\tgit branch remove &&\n'> <'\tgit branch submod &&\n'> 
          <'\tgit branch copy &&\n'> <'\tgit branch rename &&\n'> <'\tgit branch rename-ln &&\n'> <'\n'> <'\techo hello >>a &&\n'> 
          <'\tcp a d/e &&\n'> <'\to1=$(git hash-object a) &&\n'> <'\n'> <'\tgit add a d/e &&\n'> <'\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "master modifies a and d/e" &&\n'> <'\tc1=$(git rev-parse --verify HEAD) &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o1\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o1\td/e"\n'> <'\t\techo "100644 $o1 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o1 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup 2'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -rf [abcd] &&\n'> <'\tgit checkout side &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o0\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 $o0 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual &&\n'> <'\n'> 
          <'\techo goodbye >>a &&\n'> <'\to2=$(git hash-object a) &&\n'> <'\n'> <'\tgit add a &&\n'> <'\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "side modifies a" &&\n'> <'\tc2=$(git rev-parse --verify HEAD) &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o2\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 $o2 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup 3'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -rf [abcd] &&\n'> <'\tgit checkout df-1 &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o0\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 $o0 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual &&\n'> <'\n'> 
          <'\trm -f b && mkdir b && echo df-1 >b/c && git add b/c &&\n'> <'\to3=$(git hash-object b/c) &&\n'> <'\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "df-1 makes b/c" &&\n'> <'\tc3=$(git rev-parse --verify HEAD) &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o0\ta"\n'> <'\t\techo "100644 blob $o3\tb/c"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 $o0 0\ta"\n'> 
          <'\t\techo "100644 $o3 0\tb/c"\n'> <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup 4'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -rf [abcd] &&\n'> <'\tgit checkout df-2 &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o0\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 $o0 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual &&\n'> <'\n'> 
          <'\trm -f a && mkdir a && echo df-2 >a/c && git add a/c &&\n'> <'\to4=$(git hash-object a/c) &&\n'> <'\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "df-2 makes a/c" &&\n'> <'\tc4=$(git rev-parse --verify HEAD) &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o4\ta/c"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 $o4 0\ta/c"\n'> 
          <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> 
          <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup 5'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -rf [abcd] &&\n'> <'\tgit checkout remove &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o0\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 $o0 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual &&\n'> <'\n'> 
          <'\trm -f b &&\n'> <'\techo remove-conflict >a &&\n'> <'\n'> <'\tgit add a &&\n'> <'\tgit rm b &&\n'> 
          <'\to5=$(git hash-object a) &&\n'> <'\n'> <'\ttest_tick &&\n'> <'\tgit commit -m "remove removes b and modifies a" &&\n'> 
          <'\tc5=$(git rev-parse --verify HEAD) &&\n'> <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> 
          <'\t\techo "100644 blob $o5\ta"\n'> <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> 
          <'\t\techo "100644 $o5 0\ta"\n'> <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> 
          <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup 6'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -rf [abcd] &&\n'> <'\tgit checkout df-3 &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o0\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 $o0 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual &&\n'> <'\n'> 
          <'\trm -fr d && echo df-3 >d && git add d &&\n'> <'\to6=$(git hash-object d) &&\n'> <'\n'> <'\ttest_tick &&\n'> <'\tgit commit -m "df-3 makes d" &&\n'> 
          <'\tc6=$(git rev-parse --verify HEAD) &&\n'> <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> 
          <'\t\techo "100644 blob $o0\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> <'\t\techo "100644 blob $o0\tc"\n'> 
          <'\t\techo "100644 blob $o6\td"\n'> <'\t\techo "100644 $o0 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> 
          <'\t\techo "100644 $o6 0\td"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup 7'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit checkout submod &&\n'> <'\tgit rm d/e &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "remove d/e" &&\n'> <'\tgit update-index --add --cacheinfo 160000 $c1 d &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "make d/ a submodule"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup 8'>)} 
      {
        (SQ <'\n'> <'\tgit checkout rename &&\n'> <'\tgit mv a e &&\n'> <'\tgit add e &&\n'> 
          <'\ttest_tick &&\n'> <'\tgit commit -m "rename a->e" &&\n'> <'\tc7=$(git rev-parse --verify HEAD) &&\n'> 
          <'\tgit checkout rename-ln &&\n'> <'\tgit mv a e &&\n'> <'\ttest_ln_s_add e a &&\n'> <'\ttest_tick &&\n'> 
          <'\tgit commit -m "rename a->e, symlink a->e" &&\n'> <'\toln=$(printf e | git hash-object --stdin)\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'setup 9'>)} 
      {
        (SQ <'\n'> <'\tgit checkout copy &&\n'> <'\tcp a e &&\n'> <'\tgit add e &&\n'> 
          <'\ttest_tick &&\n'> <'\tgit commit -m "copy a->e"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive simple'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -fr [abcd] &&\n'> <'\tgit checkout -f "$c2" &&\n'> <'\n'> 
          <'\ttest_expect_code 1 git merge-recursive "$c0" -- "$c2" "$c1"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive result'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o0 1\ta"\n'> 
          <'\t\techo "100644 $o2 2\ta"\n'> <'\t\techo "100644 $o1 3\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> 
          <'\t\techo "100644 $o1 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'fail if the index has unresolved entries'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -fr [abcd] &&\n'> <'\tgit checkout -f "$c1" &&\n'> <'\n'> 
          <'\ttest_must_fail git merge "$c5" &&\n'> <'\ttest_must_fail git merge "$c5" 2> out &&\n'> 
          <'\ttest_i18ngrep "not possible because you have unmerged files" out &&\n'> <'\tgit add -u &&\n'> <'\ttest_must_fail git merge "$c5" 2> out &&\n'> 
          <'\ttest_i18ngrep "You have not concluded your merge" out &&\n'> <'\trm -f .git/MERGE_HEAD &&\n'> <'\ttest_must_fail git merge "$c5" 2> out &&\n'> 
          <
'\ttest_i18ngrep "Your local changes to the following files would be overwritten by merge:" out\n'
          >
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive remove conflict'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -fr [abcd] &&\n'> <'\tgit checkout -f "$c1" &&\n'> <'\n'> 
          <'\ttest_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c5"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive remove conflict'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o0 1\ta"\n'> 
          <'\t\techo "100644 $o1 2\ta"\n'> <'\t\techo "100644 $o5 3\ta"\n'> <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o1 0\td/e"\n'> 
          <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f simple'>)} 
      {
        (SQ <'\n'> <'\trm -fr [abcd] &&\n'> <'\tgit reset --hard &&\n'> <'\tgit checkout -f "$c1" &&\n'> 
          <'\n'> <'\tgit merge-recursive "$c0" -- "$c1" "$c3"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive result'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o1 0\ta"\n'> 
          <'\t\techo "100644 $o3 0\tb/c"\n'> <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o1 0\td/e"\n'> <'\t) >expected &&\n'> 
          <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f conflict'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -fr [abcd] &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit checkout -f "$c1" &&\n'> <'\n'> <'\ttest_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c4"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f conflict result'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o0 1\ta"\n'> 
          <'\t\techo "100644 $o1 2\ta"\n'> <'\t\techo "100644 $o4 0\ta/c"\n'> <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> 
          <'\t\techo "100644 $o1 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f conflict the other way'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -fr [abcd] &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit checkout -f "$c4" &&\n'> <'\n'> <'\ttest_expect_code 1 git merge-recursive "$c0" -- "$c4" "$c1"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f conflict result the other way'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o0 1\ta"\n'> 
          <'\t\techo "100644 $o1 3\ta"\n'> <'\t\techo "100644 $o4 0\ta/c"\n'> <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> 
          <'\t\techo "100644 $o1 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f conflict'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -fr [abcd] &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit checkout -f "$c1" &&\n'> <'\n'> <'\ttest_expect_code 1 git merge-recursive "$c0" -- "$c1" "$c6"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f conflict result'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o1 0\ta"\n'> 
          <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o6 3\td"\n'> <'\t\techo "100644 $o0 1\td/e"\n'> 
          <'\t\techo "100644 $o1 2\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f conflict'>)} 
      {
        (SQ <'\n'> <'\n'> <'\trm -fr [abcd] &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit checkout -f "$c6" &&\n'> <'\n'> <'\ttest_expect_code 1 git merge-recursive "$c0" -- "$c6" "$c1"\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive d/f conflict result'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o1 0\ta"\n'> 
          <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o6 2\td"\n'> <'\t\techo "100644 $o0 1\td/e"\n'> 
          <'\t\techo "100644 $o1 3\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'reset and 3-way merge'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit reset --hard "$c2" &&\n'> <'\tgit read-tree -m "$c0" "$c2" "$c1"\n'> 
          <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'reset and bind merge'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit reset --hard master &&\n'> <'\tgit read-tree --prefix=M/ master &&\n'> 
          <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o1 0\tM/a"\n'> <'\t\techo "100644 $o0 0\tM/b"\n'> 
          <'\t\techo "100644 $o0 0\tM/c"\n'> <'\t\techo "100644 $o1 0\tM/d/e"\n'> <'\t\techo "100644 $o1 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o1 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual &&\n'> <'\n'> 
          <'\tgit read-tree --prefix=a1/ master &&\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o1 0\tM/a"\n'> 
          <'\t\techo "100644 $o0 0\tM/b"\n'> <'\t\techo "100644 $o0 0\tM/c"\n'> <'\t\techo "100644 $o1 0\tM/d/e"\n'> 
          <'\t\techo "100644 $o1 0\ta"\n'> <'\t\techo "100644 $o1 0\ta1/a"\n'> <'\t\techo "100644 $o0 0\ta1/b"\n'> 
          <'\t\techo "100644 $o0 0\ta1/c"\n'> <'\t\techo "100644 $o1 0\ta1/d/e"\n'> <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> 
          <'\t\techo "100644 $o1 0\td/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual &&\n'> <'\n'> 
          <'\tgit read-tree --prefix=z/ master &&\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o1 0\tM/a"\n'> 
          <'\t\techo "100644 $o0 0\tM/b"\n'> <'\t\techo "100644 $o0 0\tM/c"\n'> <'\t\techo "100644 $o1 0\tM/d/e"\n'> 
          <'\t\techo "100644 $o1 0\ta"\n'> <'\t\techo "100644 $o1 0\ta1/a"\n'> <'\t\techo "100644 $o0 0\ta1/b"\n'> 
          <'\t\techo "100644 $o0 0\ta1/c"\n'> <'\t\techo "100644 $o1 0\ta1/d/e"\n'> <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> 
          <'\t\techo "100644 $o1 0\td/e"\n'> <'\t\techo "100644 $o1 0\tz/a"\n'> <'\t\techo "100644 $o0 0\tz/b"\n'> 
          <'\t\techo "100644 $o0 0\tz/c"\n'> <'\t\techo "100644 $o1 0\tz/d/e"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'> <'\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive w/ empty work tree - ours has rename'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tGIT_WORK_TREE="$PWD/ours-has-rename-work" &&\n'> 
          <'\t\texport GIT_WORK_TREE &&\n'> <'\t\tGIT_INDEX_FILE="$PWD/ours-has-rename-index" &&\n'> <'\t\texport GIT_INDEX_FILE &&\n'> 
          <'\t\tmkdir "$GIT_WORK_TREE" &&\n'> <'\t\tgit read-tree -i -m $c7 &&\n'> <'\t\tgit update-index --ignore-missing --refresh &&\n'> 
          <'\t\tgit merge-recursive $c0 -- $c7 $c3 &&\n'> <'\t\tgit ls-files -s >actual-files\n'> <'\t) 2>actual-err &&\n'> <'\t>expected-err &&\n'> 
          <'\tcat >expected-files <<-EOF &&\n'> <'\t100644 $o3 0\tb/c\n'> <'\t100644 $o0 0\tc\n'> <'\t100644 $o0 0\td/e\n'> <'\t100644 $o0 0\te\n'> 
          <'\tEOF\n'> <'\ttest_cmp expected-files actual-files &&\n'> <'\ttest_cmp expected-err actual-err\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive w/ empty work tree - theirs has rename'>)} 
      {
        (SQ <'\n'> <'\t(\n'> <'\t\tGIT_WORK_TREE="$PWD/theirs-has-rename-work" &&\n'> 
          <'\t\texport GIT_WORK_TREE &&\n'> <'\t\tGIT_INDEX_FILE="$PWD/theirs-has-rename-index" &&\n'> <'\t\texport GIT_INDEX_FILE &&\n'> 
          <'\t\tmkdir "$GIT_WORK_TREE" &&\n'> <'\t\tgit read-tree -i -m $c3 &&\n'> <'\t\tgit update-index --ignore-missing --refresh &&\n'> 
          <'\t\tgit merge-recursive $c0 -- $c3 $c7 &&\n'> <'\t\tgit ls-files -s >actual-files\n'> <'\t) 2>actual-err &&\n'> <'\t>expected-err &&\n'> 
          <'\tcat >expected-files <<-EOF &&\n'> <'\t100644 $o3 0\tb/c\n'> <'\t100644 $o0 0\tc\n'> <'\t100644 $o0 0\td/e\n'> <'\t100644 $o0 0\te\n'> 
          <'\tEOF\n'> <'\ttest_cmp expected-files actual-files &&\n'> <'\ttest_cmp expected-err actual-err\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge removes empty directories'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit reset --hard master &&\n'> <'\tgit checkout -b rm &&\n'> 
          <'\tgit rm d/e &&\n'> <'\tgit commit -mremoved-d/e &&\n'> <'\tgit checkout master &&\n'> <'\tgit merge -s recursive rm &&\n'> 
          <'\ttest_must_fail test -d d\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'merge-recursive simple w/submodule'>)} 
      {(SQ <'\n'> <'\n'> <'\tgit checkout submod &&\n'> <'\tgit merge remove\n'>)}
    )
    (C {(test_expect_failure)} {(SQ <'merge-recursive simple w/submodule result'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit ls-files -s >actual &&\n'> <'\t(\n'> <'\t\techo "100644 $o5 0\ta"\n'> 
          <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "160000 $c1 0\td"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive copy vs. rename'>)} 
      {
        (SQ <'\n'> <'\tgit checkout -f copy &&\n'> <'\tgit merge rename &&\n'> 
          <'\t( git ls-tree -r HEAD && git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "100644 blob $o0\tb"\n'> <'\t\techo "100644 blob $o0\tc"\n'> 
          <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 blob $o0\te"\n'> <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> 
          <'\t\techo "100644 $o0 0\td/e"\n'> <'\t\techo "100644 $o0 0\te"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_failure)} {(SQ <'merge-recursive rename vs. rename/symlink'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit checkout -f rename &&\n'> <'\tgit merge rename-ln &&\n'> 
          <'\t( git ls-tree -r HEAD ; git ls-files -s ) >actual &&\n'> <'\t(\n'> <'\t\techo "120000 blob $oln\ta"\n'> <'\t\techo "100644 blob $o0\tb"\n'> 
          <'\t\techo "100644 blob $o0\tc"\n'> <'\t\techo "100644 blob $o0\td/e"\n'> <'\t\techo "100644 blob $o0\te"\n'> 
          <'\t\techo "120000 $oln 0\ta"\n'> <'\t\techo "100644 $o0 0\tb"\n'> <'\t\techo "100644 $o0 0\tc"\n'> <'\t\techo "100644 $o0 0\td/e"\n'> 
          <'\t\techo "100644 $o0 0\te"\n'> <'\t) >expected &&\n'> <'\ttest_cmp expected actual\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merging with triple rename across D/F conflict'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard HEAD &&\n'> <'\tgit checkout -b main &&\n'> 
          <'\tgit rm -rf . &&\n'> <'\n'> <'\techo "just a file" >sub1 &&\n'> <'\tmkdir -p sub2 &&\n'> <'\techo content1 >sub2/file1 &&\n'> 
          <'\techo content2 >sub2/file2 &&\n'> <'\techo content3 >sub2/file3 &&\n'> <'\tmkdir simple &&\n'> <'\techo base >simple/bar &&\n'> 
          <'\tgit add -A &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m base &&\n'> <'\n'> <'\tgit checkout -b other &&\n'> 
          <'\techo more >>simple/bar &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -a -m changesimplefile &&\n'> <'\n'> <'\tgit checkout main &&\n'> 
          <'\tgit rm sub1 &&\n'> <'\tgit mv sub2 sub1 &&\n'> <'\ttest_tick &&\n'> <'\tgit commit -m changefiletodir &&\n'> <'\n'> 
          <'\ttest_tick &&\n'> <'\tgit merge other\n'>
        )
      }
    )
    (C {(test_expect_success)} {(SQ <'merge-recursive remembers the names of all base trees'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard HEAD &&\n'> <'\n'> 
          <'\t# more trees than static slots used by oid_to_hex()\n'> <'\tfor commit in $c0 $c2 $c4 $c5 $c6 $c7\n'> <'\tdo\n'> <'\t\tgit rev-parse "$commit^{tree}"\n'> 
          <'\tdone >trees &&\n'> <'\n'> <'\t# ignore the return code -- it only fails because the input is weird\n'> 
          <
'\ttest_must_fail git -c merge.verbosity=5 merge-recursive $(cat trees) -- $c1 $c3 >out &&\n'
          > <'\n'> <'\t# merge-recursive prints in reverse order, but we do not care\n'> 
          <'\tsort <trees >expect &&\n'> <'\tsed -n "s/^virtual //p" out | sort >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {(test_done)})
  ]
)