Code

status: show "-v" diff even for initial commit
[git.git] / t / t3600-rm.sh
index 316775ecd96208c07f3211a24de2e5ec2ee409ab..5b4d6f71387ce7f30cb7ee6b596357aa1942ab6e 100755 (executable)
@@ -12,14 +12,14 @@ test_expect_success \
     'Initialize test directory' \
     "touch -- foo bar baz 'space embedded' -q &&
      git add -- foo bar baz 'space embedded' -q &&
-     git-commit -m 'add normal files' &&
+     git commit -m 'add normal files' &&
      test_tabs=y &&
      if touch -- 'tab  embedded' 'newline
 embedded'
      then
      git add -- 'tab   embedded' 'newline
 embedded' &&
-     git-commit -m 'add files with tabs and newlines'
+     git commit -m 'add files with tabs and newlines'
      else
          say 'Your filesystem does not allow tabs in filenames.'
          test_tabs=n
@@ -187,6 +187,19 @@ test_expect_success 'but with -f it should work.' '
        test_must_fail git ls-files --error-unmatch baz
 '
 
+test_expect_failure 'refuse to remove cached empty file with modifications' '
+       touch empty &&
+       git add empty &&
+       echo content >empty &&
+       test_must_fail git rm --cached empty
+'
+
+test_expect_success 'remove intent-to-add file without --force' '
+       echo content >intent-to-add &&
+       git add -N intent-to-add
+       git rm --cached intent-to-add
+'
+
 test_expect_success 'Recursive test setup' '
        mkdir -p frotz &&
        echo qfwfq >frotz/nitfol &&
@@ -217,4 +230,25 @@ test_expect_success 'Remove nonexistent file returns nonzero exit status' '
        test_must_fail git rm nonexistent
 '
 
+test_expect_success 'Call "rm" from outside the work tree' '
+       mkdir repo &&
+       (cd repo &&
+        git init &&
+        echo something > somefile &&
+        git add somefile &&
+        git commit -m "add a file" &&
+        (cd .. &&
+         git --git-dir=repo/.git --work-tree=repo rm somefile) &&
+       test_must_fail git ls-files --error-unmatch somefile)
+'
+
+test_expect_success 'refresh index before checking if it is up-to-date' '
+
+       git reset --hard &&
+       test-chmtime -86400 frotz/nitfol &&
+       git rm frotz/nitfol &&
+       test ! -f frotz/nitfol
+
+'
+
 test_done