Use less memory in "git log"
[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 10# Setup some files to be removed, some with funny characters
d51fac53
AR
11touch -- foo bar baz 'space embedded' -q
12git-add -- foo bar baz 'space embedded' -q
13git-commit -m "add normal files"
14test_tabs=y
15if touch -- 'tab embedded' 'newline
16embedded'
17then
18git-add -- 'tab embedded' 'newline
19embedded'
20git-commit -m "add files with tabs and newlines"
21else
22 say 'Your filesystem does not allow tabs in filenames.'
23 test_tabs=n
24fi
d4a1cab5
CW
25
26test_expect_success \
3844cdc8
CW
27 'Pre-check that foo exists and is in index before git-rm foo' \
28 '[ -f foo ] && git-ls-files --error-unmatch foo'
d4a1cab5
CW
29
30test_expect_success \
31 'Test that git-rm foo succeeds' \
32 'git-rm foo'
33
3844cdc8
CW
34test_expect_success \
35 'Post-check that foo exists but is not in index after git-rm foo' \
36 '[ -f foo ] && ! git-ls-files --error-unmatch foo'
37
38test_expect_success \
39 'Pre-check that bar exists and is in index before "git-rm -f bar"' \
40 '[ -f bar ] && git-ls-files --error-unmatch bar'
d4a1cab5
CW
41
42test_expect_success \
3844cdc8 43 'Test that "git-rm -f bar" succeeds' \
d4a1cab5
CW
44 'git-rm -f bar'
45
3844cdc8
CW
46test_expect_success \
47 'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \
48 '! [ -f bar ] && ! git-ls-files --error-unmatch bar'
d4a1cab5
CW
49
50test_expect_success \
3844cdc8 51 'Test that "git-rm -- -q" succeeds (remove a file that looks like an option)' \
d4a1cab5
CW
52 'git-rm -- -q'
53
d51fac53 54test "$test_tabs" = y && test_expect_success \
3844cdc8
CW
55 "Test that \"git-rm -f\" succeeds with embedded space, tab, or newline characters." \
56 "git-rm -f 'space embedded' 'tab embedded' 'newline
57embedded'"
58
d51fac53 59if test "$test_tabs" = y; then
3844cdc8
CW
60chmod u-w .
61test_expect_failure \
62 'Test that "git-rm -f" fails if its rm fails' \
63 'git-rm -f baz'
64chmod u+w .
d51fac53 65fi
3844cdc8
CW
66
67test_expect_success \
68 'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
69 'git-ls-files --error-unmatch baz'
70
d4a1cab5 71test_done