(command.CommandList
  children: [
    (command.ShAssignment
      pairs: [
        (assign_pair
          lhs: (sh_lhs_expr.Name name:test_description)
          op: assign_op.Equal
          rhs: {(SQ <'Test of the various options to git rm.'>)}
          spids: [13]
        )
      ]
    )
    (C {<.>} {<'./test-lib.sh'>})
    (C {<test_expect_success>} {(SQ <'Initialize test directory'>)} 
      {
        (DQ <'touch -- foo bar baz \'space embedded\' -q &&\n'> 
          <'     git add -- foo bar baz \'space embedded\' -q &&\n'> <'     git commit -m \'add normal files\''>
        )
      }
    )
    (command.If
      arms: [
        (if_arm
          cond: [
            (command.AndOr
              ops: [Id.Op_DAmp]
              children: [
                (C {<test_have_prereq>} {<Id.KW_Bang '!'> <MINGW>})
                (command.Simple
                  words: [{<touch>} {<-->} {(SQ <'tab\tembedded'>)} {(SQ <'newline\n'> <embedded>)}]
                  redirects: [
                    (redir
                      op: <Id.Redir_Great '2>'>
                      loc: (redir_loc.Fd fd:2)
                      arg: {<'/dev/null'>}
                    )
                  ]
                  do_fork: T
                )
              ]
            )
          ]
          action: [(C {<test_set_prereq>} {<FUNNYNAMES>})]
          spids: [44 69]
        )
      ]
      else_action: [(C {<say>} {(SQ <'Your filesystem does not allow tabs in filenames.'>)})]
    )
    (C {<test_expect_success>} {<FUNNYNAMES>} {(SQ <'add files with funny names'>)} 
      {
        (DQ <'\n'> <'     git add -- \'tab\tembedded\' \'newline\n'> <'embedded\' &&\n'> 
          <'     git commit -m \'add files with tabs and newlines\'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Pre-check that foo exists and is in index before git rm foo'>)} 
      {(SQ <'[ -f foo ] && git ls-files --error-unmatch foo'>)}
    )
    (C {<test_expect_success>} {(SQ <'Test that git rm foo succeeds'>)} {(SQ <'git rm --cached foo'>)})
    (C {<test_expect_success>} 
      {(SQ <'Test that git rm --cached foo succeeds if the index matches the file'>)} {(SQ <'echo content >foo &&\n'> <'     git add foo &&\n'> <'     git rm --cached foo'>)}
    )
    (C {<test_expect_success>} 
      {(SQ <'Test that git rm --cached foo succeeds if the index matches the file'>)} 
      {
        (SQ <'echo content >foo &&\n'> <'     git add foo &&\n'> <'     git commit -m foo &&\n'> 
          <'     echo "other content" >foo &&\n'> <'     git rm --cached foo'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'Test that git rm --cached foo fails if the index matches neither the file nor HEAD'>)} 
      {
        (SQ <'\n'> <'     echo content >foo &&\n'> <'     git add foo &&\n'> 
          <'     git commit -m foo --allow-empty &&\n'> <'     echo "other content" >foo &&\n'> <'     git add foo &&\n'> 
          <'     echo "yet another content" >foo &&\n'> <'     test_must_fail git rm --cached foo\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'Test that git rm --cached -f foo works in case where --cached only did not'>)} 
      {
        (SQ <'echo content >foo &&\n'> <'     git add foo &&\n'> 
          <'     git commit -m foo --allow-empty &&\n'> <'     echo "other content" >foo &&\n'> <'     git add foo &&\n'> 
          <'     echo "yet another content" >foo &&\n'> <'     git rm --cached -f foo'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'Post-check that foo exists but is not in index after git rm foo'>)} {(SQ <'[ -f foo ] && test_must_fail git ls-files --error-unmatch foo'>)}
    )
    (C {<test_expect_success>} {(SQ <'Pre-check that bar exists and is in index before "git rm bar"'>)} 
      {(SQ <'[ -f bar ] && git ls-files --error-unmatch bar'>)}
    )
    (C {<test_expect_success>} {(SQ <'Test that "git rm bar" succeeds'>)} {(SQ <'git rm bar'>)})
    (C {<test_expect_success>} 
      {(SQ <'Post-check that bar does not exist and is not in index after "git rm -f bar"'>)} {(SQ <'! [ -f bar ] && test_must_fail git ls-files --error-unmatch bar'>)}
    )
    (C {<test_expect_success>} 
      {(SQ <'Test that "git rm -- -q" succeeds (remove a file that looks like an option)'>)} {(SQ <'git rm -- -q'>)}
    )
    (C {<test_expect_success>} {<FUNNYNAMES>} 
      {
        (DQ <'Test that '> (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <'git rm -f'> 
          (word_part.EscapedLiteral token:<Id.Lit_EscapedChar '\\"'>) <' succeeds with embedded space, tab, or newline characters.'>
        )
      } {(DQ <'git rm -f \'space embedded\' \'tab\tembedded\' \'newline\n'> <'embedded\''>)}
    )
    (C {<test_expect_success>} {<SANITY>} {(SQ <'Test that "git rm -f" fails if its rm fails'>)} 
      {(SQ <'\n'> <'\tchmod a-w . &&\n'> <'\ttest_must_fail git rm -f baz &&\n'> <'\tchmod 775 .\n'>)}
    )
    (C {<test_expect_success>} 
      {(SQ <'When the rm in "git rm -f" fails, it should not remove the file from the index'>)} {(SQ <'git ls-files --error-unmatch baz'>)}
    )
    (C {<test_expect_success>} {(SQ <'Remove nonexistent file with --ignore-unmatch'>)} 
      {(SQ <'\n'> <'\tgit rm --ignore-unmatch nonexistent\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'"rm" command printed'>)} 
      {
        (SQ <'\n'> <'\techo frotz > test-file &&\n'> <'\tgit add test-file &&\n'> 
          <'\tgit commit -m "add file for rm test" &&\n'> <'\tgit rm test-file > rm-output &&\n'> <'\ttest $(grep "^rm " rm-output | wc -l) = 1 &&\n'> 
          <'\trm -f test-file rm-output &&\n'> <'\tgit commit -m "remove file from rm test"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'"rm" command suppressed with --quiet'>)} 
      {
        (SQ <'\n'> <'\techo frotz > test-file &&\n'> <'\tgit add test-file &&\n'> 
          <'\tgit commit -m "add file for rm --quiet test" &&\n'> <'\tgit rm --quiet test-file > rm-output &&\n'> <'\ttest $(wc -l < rm-output) = 0 &&\n'> 
          <'\trm -f test-file rm-output &&\n'> <'\tgit commit -m "remove file from rm --quiet test"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Re-add foo and baz'>)} 
      {(SQ <'\n'> <'\tgit add foo baz &&\n'> <'\tgit ls-files --error-unmatch foo baz\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'Modify foo -- rm should refuse'>)} 
      {
        (SQ <'\n'> <'\techo >>foo &&\n'> <'\ttest_must_fail git rm foo baz &&\n'> <'\ttest -f foo &&\n'> 
          <'\ttest -f baz &&\n'> <'\tgit ls-files --error-unmatch foo baz\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Modified foo -- rm -f should work'>)} 
      {
        (SQ <'\n'> <'\tgit rm -f foo baz &&\n'> <'\ttest ! -f foo &&\n'> <'\ttest ! -f baz &&\n'> 
          <'\ttest_must_fail git ls-files --error-unmatch foo &&\n'> <'\ttest_must_fail git ls-files --error-unmatch bar\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Re-add foo and baz for HEAD tests'>)} 
      {
        (SQ <'\n'> <'\techo frotz >foo &&\n'> <'\tgit checkout HEAD -- baz &&\n'> 
          <'\tgit add foo baz &&\n'> <'\tgit ls-files --error-unmatch foo baz\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'foo is different in index from HEAD -- rm should refuse'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rm foo baz &&\n'> <'\ttest -f foo &&\n'> 
          <'\ttest -f baz &&\n'> <'\tgit ls-files --error-unmatch foo baz\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'but with -f it should work.'>)} 
      {
        (SQ <'\n'> <'\tgit rm -f foo baz &&\n'> <'\ttest ! -f foo &&\n'> <'\ttest ! -f baz &&\n'> 
          <'\ttest_must_fail git ls-files --error-unmatch foo &&\n'> <'\ttest_must_fail git ls-files --error-unmatch baz\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'refuse to remove cached empty file with modifications'>)} 
      {
        (SQ <'\n'> <'\t>empty &&\n'> <'\tgit add empty &&\n'> <'\techo content >empty &&\n'> 
          <'\ttest_must_fail git rm --cached empty\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'remove intent-to-add file without --force'>)} 
      {
        (SQ <'\n'> <'\techo content >intent-to-add &&\n'> <'\tgit add -N intent-to-add &&\n'> 
          <'\tgit rm --cached intent-to-add\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Recursive test setup'>)} 
      {
        (SQ <'\n'> <'\tmkdir -p frotz &&\n'> <'\techo qfwfq >frotz/nitfol &&\n'> 
          <'\tgit add frotz &&\n'> <'\tgit commit -m "subdir test"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Recursive without -r fails'>)} 
      {
        (SQ <'\n'> <'\ttest_must_fail git rm frotz &&\n'> <'\ttest -d frotz &&\n'> 
          <'\ttest -f frotz/nitfol\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Recursive with -r but dirty'>)} 
      {
        (SQ <'\n'> <'\techo qfwfq >>frotz/nitfol &&\n'> <'\ttest_must_fail git rm -r frotz &&\n'> 
          <'\ttest -d frotz &&\n'> <'\ttest -f frotz/nitfol\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Recursive with -r -f'>)} 
      {
        (SQ <'\n'> <'\tgit rm -f -r frotz &&\n'> <'\t! test -f frotz/nitfol &&\n'> 
          <'\t! test -d frotz\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'Remove nonexistent file returns nonzero exit status'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git rm nonexistent\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'Call "rm" from outside the work tree'>)} 
      {
        (SQ <'\n'> <'\tmkdir repo &&\n'> <'\t(cd repo &&\n'> <'\t git init &&\n'> 
          <'\t echo something > somefile &&\n'> <'\t git add somefile &&\n'> <'\t git commit -m "add a file" &&\n'> <'\t (cd .. &&\n'> 
          <'\t  git --git-dir=repo/.git --work-tree=repo rm somefile) &&\n'> <'\ttest_must_fail git ls-files --error-unmatch somefile)\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'refresh index before checking if it is up-to-date'>)} 
      {
        (SQ <'\n'> <'\n'> <'\tgit reset --hard &&\n'> <'\ttest-chmtime -86400 frotz/nitfol &&\n'> 
          <'\tgit rm frotz/nitfol &&\n'> <'\ttest ! -f frotz/nitfol\n'> <'\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'choking "git rm" should not let it die with cruft'>)} 
      {
        (SQ <'\n'> <'\tgit reset -q --hard &&\n'> 
          <'\ttest_when_finished "rm -f .git/index.lock && git reset -q --hard" &&\n'> <'\ti=0 &&\n'> <'\twhile test $i -lt 12000\n'> <'\tdo\n'> 
          <'\t    echo "100644 1234567890123456789012345678901234567890 0\tsome-file-$i"\n'> <'\t    i=$(( $i + 1 ))\n'> <'\tdone | git update-index --index-info &&\n'> 
          <'\tgit rm -n "some-file-*" | : &&\n'> <'\ttest_path_is_missing .git/index.lock\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm removes subdirectories recursively'>)} 
      {
        (SQ <'\n'> <'\tmkdir -p dir/subdir/subsubdir &&\n'> 
          <'\techo content >dir/subdir/subsubdir/file &&\n'> <'\tgit add dir/subdir/subsubdir/file &&\n'> <'\tgit rm -f dir/subdir/subsubdir/file &&\n'> 
          <'\t! test -d dir\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 665
              stdin_parts: [<'M  .gitmodules\n'> <'D  submod\n'>]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.modified>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 677
              stdin_parts: [<' M submod\n'>]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.cached>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 689
              stdin_parts: [<'D  submod\n'>]
            )
        )
      ]
      do_fork: T
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.both_deleted>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 701
              stdin_parts: [<'D  .gitmodules\n'> <'D  submod\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'rm removes empty submodules from work tree'>)} 
      {
        (SQ <'\n'> <'\tmkdir submod &&\n'> 
          <'\tgit update-index --add --cacheinfo 160000 $(git rev-parse HEAD) submod &&\n'> <'\tgit config -f .gitmodules submodule.sub.url ./. &&\n'> 
          <'\tgit config -f .gitmodules submodule.sub.path submod &&\n'> <'\tgit submodule init &&\n'> <'\tgit add .gitmodules &&\n'> <'\tgit commit -m "add submodule" &&\n'> 
          <'\tgit rm submod &&\n'> <'\ttest ! -e submod &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\ttest_cmp expect actual &&\n'> <'\ttest_must_fail git config -f .gitmodules submodule.sub.url &&\n'> 
          <'\ttest_must_fail git config -f .gitmodules submodule.sub.path\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm removes removed submodule from index and .gitmodules'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> <'\trm -rf submod &&\n'> 
          <'\tgit rm submod &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual &&\n'> 
          <'\ttest_must_fail git config -f .gitmodules submodule.sub.url &&\n'> <'\ttest_must_fail git config -f .gitmodules submodule.sub.path\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm removes work tree of unmodified submodules'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> <'\tgit rm submod &&\n'> 
          <'\ttest ! -d submod &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual &&\n'> 
          <'\ttest_must_fail git config -f .gitmodules submodule.sub.url &&\n'> <'\ttest_must_fail git config -f .gitmodules submodule.sub.path\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm removes a submodule with a trailing /'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> <'\tgit rm submod/ &&\n'> 
          <'\ttest ! -d submod &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm fails when given a file with a trailing /'>)} 
      {(SQ <'\n'> <'\ttest_must_fail git rm empty/\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'rm succeeds when given a directory with a trailing /'>)} 
      {(SQ <'\n'> <'\tgit rm -r frotz/\n'>)}
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a populated submodule with different HEAD fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> 
          <'\t\tgit checkout HEAD^\n'> <'\t) &&\n'> <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> 
          <'\ttest -f submod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\ttest_cmp expect.modified actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual &&\n'> 
          <'\ttest_must_fail git config -f .gitmodules submodule.sub.url &&\n'> <'\ttest_must_fail git config -f .gitmodules submodule.sub.path\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm --cached leaves work tree of populated submodules and .gitmodules alone'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> 
          <'\tgit rm --cached submod &&\n'> <'\ttest -d submod &&\n'> <'\ttest -f submod/.git &&\n'> <'\tgit status -s -uno >actual &&\n'> 
          <'\ttest_cmp expect.cached actual &&\n'> <'\tgit config -f .gitmodules submodule.sub.url &&\n'> 
          <'\tgit config -f .gitmodules submodule.sub.path\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm --dry-run does not touch the submodule or .gitmodules'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> 
          <'\tgit rm -n submod &&\n'> <'\ttest -f submod/.git &&\n'> <'\tgit diff-index --exit-code HEAD\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm does not complain when no .gitmodules file is found'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> 
          <'\tgit rm .gitmodules &&\n'> <'\tgit rm submod >actual 2>actual.err &&\n'> <'\t! test -s actual.err &&\n'> 
          <'\t! test -d submod &&\n'> <'\t! test -f submod/.git &&\n'> <'\tgit status -s -uno >actual &&\n'> 
          <'\ttest_cmp expect.both_deleted actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm will error out on a modified .gitmodules file unless staged'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> 
          <'\tgit config -f .gitmodules foo.bar true &&\n'> <'\ttest_must_fail git rm submod >actual 2>actual.err &&\n'> <'\ttest -s actual.err &&\n'> 
          <'\ttest -d submod &&\n'> <'\ttest -f submod/.git &&\n'> <'\tgit diff-files --quiet -- submod &&\n'> 
          <'\tgit add .gitmodules &&\n'> <'\tgit rm submod >actual 2>actual.err &&\n'> <'\t! test -s actual.err &&\n'> 
          <'\t! test -d submod &&\n'> <'\t! test -f submod/.git &&\n'> <'\tgit status -s -uno >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm issues a warning when section is not found in .gitmodules'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> 
          <'\tgit config -f .gitmodules --remove-section submodule.sub &&\n'> <'\tgit add .gitmodules &&\n'> 
          <
'\techo "warning: Could not find section in .gitmodules where path=submod" >expect.err &&\n'
          > <'\tgit rm submod >actual 2>actual.err &&\n'> <'\ttest_i18ncmp expect.err actual.err &&\n'> 
          <'\t! test -d submod &&\n'> <'\t! test -f submod/.git &&\n'> <'\tgit status -s -uno >actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a populated submodule with modifications fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> 
          <'\t\techo X >empty\n'> <'\t) &&\n'> <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> 
          <'\ttest -f submod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\ttest_cmp expect.modified actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a populated submodule with untracked files fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> 
          <'\t\techo X >untracked\n'> <'\t) &&\n'> <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> 
          <'\ttest -f submod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\ttest_cmp expect.modified actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'setup submodule conflict'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> 
          <'\tgit checkout -b branch1 &&\n'> <'\techo 1 >nitfol &&\n'> <'\tgit add nitfol &&\n'> <'\tgit commit -m "added nitfol 1" &&\n'> 
          <'\tgit checkout -b branch2 master &&\n'> <'\techo 2 >nitfol &&\n'> <'\tgit add nitfol &&\n'> <'\tgit commit -m "added nitfol 2" &&\n'> 
          <'\tgit checkout -b conflict1 master &&\n'> <'\t(cd submod &&\n'> <'\t\tgit fetch &&\n'> <'\t\tgit checkout branch1\n'> <'\t) &&\n'> 
          <'\tgit add submod &&\n'> <'\tgit commit -m "submod 1" &&\n'> <'\tgit checkout -b conflict2 master &&\n'> <'\t(cd submod &&\n'> 
          <'\t\tgit checkout branch2\n'> <'\t) &&\n'> <'\tgit add submod &&\n'> <'\tgit commit -m "submod 2"\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.conflict>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1031
              stdin_parts: [<'UU submod\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'rm removes work tree of unmodified conflicted submodule'>)} 
      {
        (SQ <'\n'> <'\tgit checkout conflict1 &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit submodule update &&\n'> <'\ttest_must_fail git merge conflict2 &&\n'> <'\tgit rm submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a conflicted populated submodule with different HEAD fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit checkout conflict1 &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> <'\t\tgit checkout HEAD^\n'> <'\t) &&\n'> 
          <'\ttest_must_fail git merge conflict2 &&\n'> <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> <'\ttest -f submod/.git &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect.conflict actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual &&\n'> 
          <'\ttest_must_fail git config -f .gitmodules submodule.sub.url &&\n'> <'\ttest_must_fail git config -f .gitmodules submodule.sub.path\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a conflicted populated submodule with modifications fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit checkout conflict1 &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> <'\t\techo X >empty\n'> <'\t) &&\n'> <'\ttest_must_fail git merge conflict2 &&\n'> 
          <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> <'\ttest -f submod/.git &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect.conflict actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual &&\n'> 
          <'\ttest_must_fail git config -f .gitmodules submodule.sub.url &&\n'> <'\ttest_must_fail git config -f .gitmodules submodule.sub.path\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a conflicted populated submodule with untracked files fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit checkout conflict1 &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> <'\t\techo X >untracked\n'> <'\t) &&\n'> 
          <'\ttest_must_fail git merge conflict2 &&\n'> <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> <'\ttest -f submod/.git &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect.conflict actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a conflicted populated submodule with a .git directory fails even when forced'>)} 
      {
        (SQ <'\n'> <'\tgit checkout conflict1 &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> <'\t\trm .git &&\n'> <'\t\tcp -R ../.git/modules/sub .git &&\n'> 
          <'\t\tGIT_WORK_TREE=. git config --unset core.worktree\n'> <'\t) &&\n'> <'\ttest_must_fail git merge conflict2 &&\n'> <'\ttest_must_fail git rm submod &&\n'> 
          <'\ttest -d submod &&\n'> <'\ttest -d submod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\ttest_cmp expect.conflict actual &&\n'> <'\ttest_must_fail git rm -f submod &&\n'> <'\ttest -d submod &&\n'> <'\ttest -d submod/.git &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect.conflict actual &&\n'> <'\tgit merge --abort &&\n'> <'\trm -rf submod\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm of a conflicted unpopulated submodule succeeds'>)} 
      {
        (SQ <'\n'> <'\tgit checkout conflict1 &&\n'> <'\tgit reset --hard &&\n'> 
          <'\ttest_must_fail git merge conflict2 &&\n'> <'\tgit rm submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a populated submodule with a .git directory fails even when forced'>)} 
      {
        (SQ <'\n'> <'\tgit checkout -f master &&\n'> <'\tgit reset --hard &&\n'> 
          <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> <'\t\trm .git &&\n'> <'\t\tcp -R ../.git/modules/sub .git &&\n'> 
          <'\t\tGIT_WORK_TREE=. git config --unset core.worktree\n'> <'\t) &&\n'> <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> 
          <'\ttest -d submod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\t! test -s actual &&\n'> 
          <'\ttest_must_fail git rm -f submod &&\n'> <'\ttest -d submod &&\n'> <'\ttest -d submod/.git &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\t! test -s actual &&\n'> <'\trm -rf submod\n'>
        )
      }
    )
    (command.Simple
      words: [{<cat>}]
      redirects: [
        (redir op:<Id.Redir_Great '>'> loc:(redir_loc.Fd fd:1) arg:{<expect.deepmodified>})
        (redir
          op: <Id.Redir_DLess '<<'>
          loc: (redir_loc.Fd fd:0)
          arg: 
            (redir_param.MultiLine
              here_begin: {<EOF>}
              here_end_span_id: 1227
              stdin_parts: [<' M submod/subsubmod\n'>]
            )
        )
      ]
      do_fork: T
    )
    (C {<test_expect_success>} {(SQ <'setup subsubmodule'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update &&\n'> <'\t(cd submod &&\n'> 
          <'\t\tgit update-index --add --cacheinfo 160000 $(git rev-parse HEAD) subsubmod &&\n'> <'\t\tgit config -f .gitmodules submodule.sub.url ../. &&\n'> 
          <'\t\tgit config -f .gitmodules submodule.sub.path subsubmod &&\n'> <'\t\tgit submodule init &&\n'> <'\t\tgit add .gitmodules &&\n'> 
          <'\t\tgit commit -m "add subsubmodule" &&\n'> <'\t\tgit submodule update subsubmod\n'> <'\t) &&\n'> <'\tgit commit -a -m "added deep submodule"\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm recursively removes work tree of unmodified submodules'>)} 
      {
        (SQ <'\n'> <'\tgit rm submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a populated nested submodule with different nested HEAD fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update --recursive &&\n'> 
          <'\t(cd submod/subsubmod &&\n'> <'\t\tgit checkout HEAD^\n'> <'\t) &&\n'> <'\ttest_must_fail git rm submod &&\n'> 
          <'\ttest -d submod &&\n'> <'\ttest -f submod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\ttest_cmp expect.modified actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a populated nested submodule with nested modifications fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update --recursive &&\n'> 
          <'\t(cd submod/subsubmod &&\n'> <'\t\techo X >empty\n'> <'\t) &&\n'> <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> 
          <'\ttest -f submod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\ttest_cmp expect.modified actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'rm of a populated nested submodule with nested untracked files fails unless forced'>)} 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update --recursive &&\n'> 
          <'\t(cd submod/subsubmod &&\n'> <'\t\techo X >untracked\n'> <'\t) &&\n'> <'\ttest_must_fail git rm submod &&\n'> 
          <'\ttest -d submod &&\n'> <'\ttest -f submod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\ttest_cmp expect.modified actual &&\n'> <'\tgit rm -f submod &&\n'> <'\ttest ! -d submod &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\ttest_cmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {
        (SQ 
          <'rm of a populated nested submodule with a nested .git directory fails even when forced'>
        )
      } 
      {
        (SQ <'\n'> <'\tgit reset --hard &&\n'> <'\tgit submodule update --recursive &&\n'> 
          <'\t(cd submod/subsubmod &&\n'> <'\t\trm .git &&\n'> <'\t\tcp -R ../../.git/modules/sub/modules/sub .git &&\n'> 
          <'\t\tGIT_WORK_TREE=. git config --unset core.worktree\n'> <'\t) &&\n'> <'\ttest_must_fail git rm submod &&\n'> <'\ttest -d submod &&\n'> 
          <'\ttest -d submod/subsubmod/.git &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\t! test -s actual &&\n'> 
          <'\ttest_must_fail git rm -f submod &&\n'> <'\ttest -d submod &&\n'> <'\ttest -d submod/subsubmod/.git &&\n'> 
          <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> <'\t! test -s actual &&\n'> <'\trm -rf submod\n'>
        )
      }
    )
    (C {<test_expect_success>} 
      {(SQ <'checking out a commit after submodule removal needs manual updates'>)} 
      {
        (SQ <'\n'> <'\tgit commit -m "submodule removal" submod &&\n'> <'\tgit checkout HEAD^ &&\n'> 
          <'\tgit submodule update &&\n'> <'\tgit checkout -q HEAD^ 2>actual &&\n'> <'\tgit checkout -q master 2>actual &&\n'> 
          <'\ttest_i18ngrep "^warning: unable to rmdir submod:" actual &&\n'> <'\tgit status -s submod >actual &&\n'> <'\techo "?? submod/" >expected &&\n'> 
          <'\ttest_cmp expected actual &&\n'> <'\trm -rf submod &&\n'> <'\tgit status -s -uno --ignore-submodules=none > actual &&\n'> 
          <'\t! test -s actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm of d/f when d has become a non-directory'>)} 
      {
        (SQ <'\n'> <'\trm -rf d &&\n'> <'\tmkdir d &&\n'> <'\t>d/f &&\n'> <'\tgit add d &&\n'> 
          <'\trm -rf d &&\n'> <'\t>d &&\n'> <'\tgit rm d/f &&\n'> <'\ttest_must_fail git rev-parse --verify :d/f &&\n'> 
          <'\ttest_path_is_file d\n'>
        )
      }
    )
    (C {<test_expect_success>} {<SYMLINKS>} {(SQ <'rm of d/f when d has become a dangling symlink'>)} 
      {
        (SQ <'\n'> <'\trm -rf d &&\n'> <'\tmkdir d &&\n'> <'\t>d/f &&\n'> <'\tgit add d &&\n'> 
          <'\trm -rf d &&\n'> <'\tln -s nonexistent d &&\n'> <'\tgit rm d/f &&\n'> 
          <'\ttest_must_fail git rev-parse --verify :d/f &&\n'> <'\ttest -h d &&\n'> <'\ttest_path_is_missing d\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm of file when it has become a directory'>)} 
      {
        (SQ <'\n'> <'\trm -rf d &&\n'> <'\t>d &&\n'> <'\tgit add d &&\n'> <'\trm -f d &&\n'> 
          <'\tmkdir d &&\n'> <'\t>d/f &&\n'> <'\ttest_must_fail git rm d &&\n'> <'\tgit rev-parse --verify :d &&\n'> 
          <'\ttest_path_is_file d/f\n'>
        )
      }
    )
    (C {<test_expect_success>} {<SYMLINKS>} {(SQ <'rm across a symlinked leading path (no index)'>)} 
      {
        (SQ <'\n'> <'\trm -rf d e &&\n'> <'\tmkdir e &&\n'> <'\techo content >e/f &&\n'> 
          <'\tln -s e d &&\n'> <'\tgit add -A e d &&\n'> <'\tgit commit -m "symlink d to e, e/f exists" &&\n'> 
          <'\ttest_must_fail git rm d/f &&\n'> <'\tgit rev-parse --verify :d &&\n'> <'\tgit rev-parse --verify :e/f &&\n'> <'\ttest -h d &&\n'> 
          <'\ttest_path_is_file e/f\n'>
        )
      }
    )
    (C {<test_expect_failure>} {<SYMLINKS>} {(SQ <'rm across a symlinked leading path (w/ index)'>)} 
      {
        (SQ <'\n'> <'\trm -rf d e &&\n'> <'\tmkdir d &&\n'> <'\techo content >d/f &&\n'> 
          <'\tgit add -A e d &&\n'> <'\tgit commit -m "d/f exists" &&\n'> <'\tmv d e &&\n'> <'\tln -s e d &&\n'> 
          <'\ttest_must_fail git rm d/f &&\n'> <'\tgit rev-parse --verify :d/f &&\n'> <'\ttest -h d &&\n'> <'\ttest_path_is_file e/f\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'setup for testing rm messages'>)} 
      {(SQ <'\n'> <'\t>bar.txt &&\n'> <'\t>foo.txt &&\n'> <'\tgit add bar.txt foo.txt\n'>)}
    )
    (C {<test_expect_success>} {(SQ <'rm files with different staged content'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\terror: the following files have staged content different from both the\n'> <'\tfile and the HEAD:\n'> <'\t    bar.txt\n'> <'\t    foo.txt\n'> <'\t(use -f to force removal)\n'> 
          <'\tEOF\n'> <'\techo content1 >foo.txt &&\n'> <'\techo content1 >bar.txt &&\n'> 
          <'\ttest_must_fail git rm foo.txt bar.txt 2>actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm files with different staged content without hints'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\terror: the following files have staged content different from both the\n'> <'\tfile and the HEAD:\n'> <'\t    bar.txt\n'> <'\t    foo.txt\n'> <'\tEOF\n'> 
          <'\techo content2 >foo.txt &&\n'> <'\techo content2 >bar.txt &&\n'> 
          <'\ttest_must_fail git -c advice.rmhints=false rm foo.txt bar.txt 2>actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm file with local modification'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\terror: the following file has local modifications:\n'> <'\t    foo.txt\n'> <'\t(use --cached to keep the file, or -f to force removal)\n'> <'\tEOF\n'> 
          <'\tgit commit -m "testing rm 3" &&\n'> <'\techo content3 >foo.txt &&\n'> <'\ttest_must_fail git rm foo.txt 2>actual &&\n'> 
          <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm file with local modification without hints'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\terror: the following file has local modifications:\n'> <'\t    bar.txt\n'> <'\tEOF\n'> <'\techo content4 >bar.txt &&\n'> 
          <'\ttest_must_fail git -c advice.rmhints=false rm bar.txt 2>actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm file with changes in the index'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\terror: the following file has changes staged in the index:\n'> <'\t    foo.txt\n'> <'\t(use --cached to keep the file, or -f to force removal)\n'> <'\tEOF\n'> 
          <'\tgit reset --hard &&\n'> <'\techo content5 >foo.txt &&\n'> <'\tgit add foo.txt &&\n'> 
          <'\ttest_must_fail git rm foo.txt 2>actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm file with changes in the index without hints'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\terror: the following file has changes staged in the index:\n'> <'\t    foo.txt\n'> <'\tEOF\n'> 
          <'\ttest_must_fail git -c advice.rmhints=false rm foo.txt 2>actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm files with two different errors'>)} 
      {
        (SQ <'\n'> <'\tcat >expect <<-\\EOF &&\n'> 
          <'\terror: the following file has staged content different from both the\n'> <'\tfile and the HEAD:\n'> <'\t    foo1.txt\n'> <'\t(use -f to force removal)\n'> 
          <'\terror: the following file has changes staged in the index:\n'> <'\t    bar1.txt\n'> <'\t(use --cached to keep the file, or -f to force removal)\n'> <'\tEOF\n'> 
          <'\techo content >foo1.txt &&\n'> <'\tgit add foo1.txt &&\n'> <'\techo content6 >foo1.txt &&\n'> <'\techo content6 >bar1.txt &&\n'> 
          <'\tgit add bar1.txt &&\n'> <'\ttest_must_fail git rm bar1.txt foo1.txt 2>actual &&\n'> <'\ttest_i18ncmp expect actual\n'>
        )
      }
    )
    (C {<test_expect_success>} {(SQ <'rm empty string should invoke warning'>)} 
      {
        (SQ <'\n'> <'\tgit rm -rf "" 2>output &&\n'> 
          <'\ttest_i18ngrep "warning: empty strings" output\n'>
        )
      }
    )
    (C {<test_done>})
  ]
)