aboutsummaryrefslogtreecommitdiff
path: root/t/t3600-rm.sh
diff options
context:
space:
mode:
authorCarl Worth <cworth@cworth.org>2006-02-21 15:04:51 -0800
committerJunio C Hamano <junkio@cox.net>2006-02-22 17:10:42 -0800
commitd4a1cab541be0c276b38285c8b33050ea411eacf (patch)
treefa392a19be606f1f90e0792d8407df3a4bf09969 /t/t3600-rm.sh
parent2cf3be1d31b322cf45640f3019a32d19a8a9b6f8 (diff)
downloadgit-d4a1cab541be0c276b38285c8b33050ea411eacf.tar.gz
git-d4a1cab541be0c276b38285c8b33050ea411eacf.tar.xz
Add new git-rm command with documentation
This adds a git-rm command which provides convenience similar to git-add, (and a bit more since it takes care of the rm as well if given -f). Like git-add, git-rm expands the given path names through git-ls-files. This means it only acts on files listed in the index. And it does act recursively on directories by default, (no -r needed as in the case of rm itself). When it recurses, it does not remove empty directories that are left behind. Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 't/t3600-rm.sh')
-rwxr-xr-xt/t3600-rm.sh42
1 files changed, 42 insertions, 0 deletions
diff --git a/t/t3600-rm.sh b/t/t3600-rm.sh
new file mode 100755
index 000000000..841573210
--- /dev/null
+++ b/t/t3600-rm.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Carl D. Worth
+#
+
+test_description='Test of the various options to git-rm.'
+
+. ./test-lib.sh
+
+# Setup some files to be removed
+touch foo bar
+git-add foo bar
+# Need one to test --
+touch -- -q
+git update-index --add -- -q
+git-commit -m "add foo, bar, and -q"
+
+test_expect_success \
+ 'Pre-check that foo is in index before git-rm foo' \
+ 'git-ls-files --error-unmatch foo'
+
+test_expect_success \
+ 'Test that git-rm foo succeeds' \
+ 'git-rm foo'
+
+test_expect_failure \
+ 'Post-check that foo is not in index after git-rm foo' \
+ 'git-ls-files --error-unmatch foo'
+
+test_expect_success \
+ 'Test that "git-rm -f bar" works' \
+ 'git-rm -f bar'
+
+test_expect_failure \
+ 'Post-check that bar no longer exists' \
+ '[ -f bar ]'
+
+test_expect_success \
+ 'Test that "git-rm -- -q" works to delete a file named -q' \
+ 'git-rm -- -q'
+
+test_done