git-mv: fix moves into a subdir from outside
[git/git.git] / t / t3600-rm.sh
CommitLineData
d4a1cab5
CW
1#!/bin/sh
2#
3# Copyright (c) 2006 Carl D. Worth
4#
5
6test_description='Test of the various options to git-rm.'
7
8. ./test-lib.sh
9
3844cdc8
CW
10# Setup some files to be removed, some with funny characters
11touch -- foo bar baz 'space embedded' 'tab embedded' 'newline
12embedded' -q
13git-add -- foo bar baz 'space embedded' 'tab embedded' 'newline
14embedded' -q
15git-commit -m "add files"
d4a1cab5
CW
16
17test_expect_success \
3844cdc8
CW
18 'Pre-check that foo exists and is in index before git-rm foo' \
19 '[ -f foo ] && git-ls-files --error-unmatch foo'
d4a1cab5
CW
20
21test_expect_success \
22 'Test that git-rm foo succeeds' \
23 'git-rm foo'
24
3844cdc8
CW
25test_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'
28
29test_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'
d4a1cab5
CW
32
33test_expect_success \
3844cdc8 34 'Test that "git-rm -f bar" succeeds' \
d4a1cab5
CW
35 'git-rm -f bar'
36
3844cdc8
CW
37test_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'
d4a1cab5
CW
40
41test_expect_success \
3844cdc8 42 'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \
d4a1cab5
CW
43 'git-rm -- -q'
44
3844cdc8
CW
45test_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
48embedded'"
49
50chmod u-w .
51test_expect_failure \
52 'Test that "git-rm -f" fails if its rm fails' \
53 'git-rm -f baz'
54chmod u+w .
55
56test_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'
59
d4a1cab5 60test_done