t3600: update the test for updated git rm
Signed-off-by: Junio C Hamano <junkio@cox.net>
Junio C Hamano committed
Dec 25, 2006 at 03:11 UTC
467e1b5383c214e9562b2dc575ac027c54aa4fba
1 file changed
+74
-4
t/t3600-rm.sh
+74
-4
@@ -43,19 +43,19 @@ test_expect_success \
43
44
test_expect_success \
45
'Test that git-rm foo succeeds' \
46
- 'git-rm foo'
46
+ 'git-rm --cached foo'
47
48
test_expect_success \
49
'Post-check that foo exists but is not in index after git-rm foo' \
50
'[ -f foo ] && ! git-ls-files --error-unmatch foo'
51
52
test_expect_success \
53
- 'Pre-check that bar exists and is in index before "git-rm -f bar"' \
53
+ 'Pre-check that bar exists and is in index before "git-rm bar"' \
54
'[ -f bar ] && git-ls-files --error-unmatch bar'
55
56
test_expect_success \
57
- 'Test that "git-rm -f bar" succeeds' \
58
- 'git-rm -f bar'
57
+ 'Test that "git-rm bar" succeeds' \
58
+ 'git-rm bar'
59
60
test_expect_success \
61
'Post-check that bar does not exist and is not in index after "git-rm -f bar"' \
@@ -84,4 +84,74 @@ test_expect_success \
84
'When the rm in "git-rm -f" fails, it should not remove the file from the index' \
85
'git-ls-files --error-unmatch baz'
86
87
+# Now, failure cases.
88
+test_expect_success 'Re-add foo and baz' '
89
+ git add foo baz &&
90
+ git ls-files --error-unmatch foo baz
91
+'
92
+
93
+test_expect_success 'Modify foo -- rm should refuse' '
94
+ echo >>foo &&
95
+ ! git rm foo baz &&
96
+ test -f foo &&
97
+ test -f baz &&
98
+ git ls-files --error-unmatch foo baz
99
+'
100
+
101
+test_expect_success 'Modified foo -- rm -f should work' '
102
+ git rm -f foo baz &&
103
+ test ! -f foo &&
104
+ test ! -f baz &&
105
+ ! git ls-files --error-unmatch foo &&
106
+ ! git ls-files --error-unmatch bar
107
+'
108
+
109
+test_expect_success 'Re-add foo and baz for HEAD tests' '
110
+ echo frotz >foo &&
111
+ git checkout HEAD -- baz &&
112
+ git add foo baz &&
113
+ git ls-files --error-unmatch foo baz
114
+'
115
+
116
+test_expect_success 'foo is different in index from HEAD -- rm should refuse' '
117
+ ! git rm foo baz &&
118
+ test -f foo &&
119
+ test -f baz &&
120
+ git ls-files --error-unmatch foo baz
121
+'
122
+
123
+test_expect_success 'but with -f it should work.' '
124
+ git rm -f foo baz &&
125
+ test ! -f foo &&
126
+ test ! -f baz &&
127
+ ! git ls-files --error-unmatch foo
128
+ ! git ls-files --error-unmatch baz
129
+'
130
+
131
+test_expect_success 'Recursive test setup' '
132
+ mkdir -p frotz &&
133
+ echo qfwfq >frotz/nitfol &&
134
+ git add frotz &&
135
+ git commit -m "subdir test"
136
+'
137
+
138
+test_expect_success 'Recursive without -r fails' '
139
+ ! git rm frotz &&
140
+ test -d frotz &&
141
+ test -f frotz/nitfol
142
+'
143
+
144
+test_expect_success 'Recursive with -r but dirty' '
145
+ echo qfwfq >>frotz/nitfol
146
+ ! git rm -r frotz &&
147
+ test -d frotz &&
148
+ test -f frotz/nitfol
149
+'
150
+
151
+test_expect_success 'Recursive with -r -f' '
152
+ git rm -f -r frotz &&
153
+ ! test -f frotz/nitfol &&
154
+ ! test -d frotz
155
+'
156
+
157
test_done