1 #!/bin/sh
2 #
3 # Copyright (c) 2006 Carl D. Worth
4 #
6 test_description='Test of the various options to git-rm.'
8 . ./test-lib.sh
10 # Setup some files to be removed, some with funny characters
11 touch -- foo bar baz 'space embedded' 'tab embedded' 'newline
12 embedded' -q
13 git-add -- foo bar baz 'space embedded' 'tab embedded' 'newline
14 embedded' -q
15 git-commit -m "add files"
17 test_expect_success \
18 'Pre-check that foo exists and is in index before git-rm foo' \
19 '[ -f foo ] && git-ls-files --error-unmatch foo'
21 test_expect_success \
22 'Test that git-rm foo succeeds' \
23 'git-rm foo'
25 test_expect_success \
26 'Post-check that foo exists but is not in index after git-rm foo' \
27 '[ -f foo ] && ! git-ls-files --error-unmatch foo'
29 test_expect_success \
30 'Pre-check that bar exists and is in index before "git-rm -f bar"' \
31 '[ -f bar ] && git-ls-files --error-unmatch bar'
33 test_expect_success \
34 'Test that "git-rm -f bar" succeeds' \
35 'git-rm -f bar'
37 test_expect_success \
38 'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \
39 '! [ -f bar ] && ! git-ls-files --error-unmatch bar'
41 test_expect_success \
42 'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \
43 'git-rm -- -q'
45 test_expect_success \
46 "Test that \"git-rm -f\" succeeds with embedded space, tab, or newline characters." \
47 "git-rm -f 'space embedded' 'tab embedded' 'newline
48 embedded'"
50 chmod u-w .
51 test_expect_failure \
52 'Test that "git-rm -f" fails if its rm fails' \
53 'git-rm -f baz'
54 chmod u+w .
56 test_expect_success \
57 'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
58 'git-ls-files --error-unmatch baz'
60 test_done