3 # Copyright (c) 2006 Carl D. Worth
6 test_description='Test of the various options to git-rm.'
10 # Setup some files to be removed, some with funny characters
11 touch -- foo bar baz 'space embedded' -q
12 git-add -- foo bar baz 'space embedded' -q
13 git-commit -m "add normal files"
15 if touch -- 'tab embedded' 'newline
18 git-add -- 'tab embedded' 'newline
20 git-commit -m "add files with tabs and newlines"
22 say 'Your filesystem does not allow tabs in filenames.'
26 # Later we will try removing an unremovable path to make sure
27 # git-rm barfs, but if the test is run as root that cannot be
32 test -f test-file && test_failed_remove=y
37 'Pre-check that foo exists and is in index before git-rm foo' \
38 '[ -f foo ] && git-ls-files --error-unmatch foo'
41 'Test that git-rm foo succeeds' \
45 'Post-check that foo exists but is not in index after git-rm foo' \
46 '[ -f foo ] && ! git-ls-files --error-unmatch foo'
49 'Pre-check that bar exists and is in index before "git-rm -f bar"' \
50 '[ -f bar ] && git-ls-files --error-unmatch bar'
53 'Test that "git-rm -f bar" succeeds' \
57 'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \
58 '! [ -f bar ] && ! git-ls-files --error-unmatch bar'
61 'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \
64 test "$test_tabs" = y && test_expect_success \
65 "Test that \"git-rm -f\" succeeds with embedded space, tab, or newline characters." \
66 "git-rm -f 'space embedded' 'tab embedded' 'newline
69 if test "$test_failed_remove" = y; then
72 'Test that "git-rm -f" fails if its rm fails' \
76 test_expect_success 'skipping removal failure (perhaps running as root?)' :
80 'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
81 'git-ls-files --error-unmatch baz'