t3600: modernize style
The tests in `t3600-rm.sh` were written long time ago, and has a lot of style violations, including the mixed use of tabs and spaces, not having the title and the opening quote of the body on the first line of the tests, and other shell script style violations. Update it to match the CodingGuidelines. Signed-off-by: Rohit Ashiwal <rohit.ashiwal265@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Rohit Ashiwal committed
Mar 4, 2019 at 17:38 UTC
b5368c23c193fdbb634aaaf82f03f1a2eebe7641
1 file changed
+107
-100
t/t3600-rm.sh
+107
-100
@@ -8,91 +8,92 @@ test_description='Test of the various options to git rm.'
8
. ./test-lib.sh
9
10
# Setup some files to be removed, some with funny characters
11
-test_expect_success \
12
- 'Initialize test directory' \
13
- "touch -- foo bar baz 'space embedded' -q &&
14
- git add -- foo bar baz 'space embedded' -q &&
15
- git commit -m 'add normal files'"
11
+test_expect_success 'Initialize test directory' '
12
+ touch -- foo bar baz "space embedded" -q &&
13
+ git add -- foo bar baz "space embedded" -q &&
14
+ git commit -m "add normal files"
15
+'
16
17
-if test_have_prereq !FUNNYNAMES; then
17
+if test_have_prereq !FUNNYNAMES
18
+then
19
say 'Your filesystem does not allow tabs in filenames.'
20
fi
21
21
-test_expect_success FUNNYNAMES 'add files with funny names' "
22
- touch -- 'tab embedded' 'newline
23
-embedded' &&
24
- git add -- 'tab embedded' 'newline
25
-embedded' &&
26
- git commit -m 'add files with tabs and newlines'
27
-"
28
-
29
-test_expect_success \
30
- 'Pre-check that foo exists and is in index before git rm foo' \
31
- '[ -f foo ] && git ls-files --error-unmatch foo'
32
-
33
-test_expect_success \
34
- 'Test that git rm foo succeeds' \
35
- 'git rm --cached foo'
36
-
37
-test_expect_success \
38
- 'Test that git rm --cached foo succeeds if the index matches the file' \
39
- 'echo content >foo &&
40
- git add foo &&
41
- git rm --cached foo'
42
-
43
-test_expect_success \
44
- 'Test that git rm --cached foo succeeds if the index matches the file' \
45
- 'echo content >foo &&
46
- git add foo &&
47
- git commit -m foo &&
48
- echo "other content" >foo &&
49
- git rm --cached foo'
50
-
51
-test_expect_success \
52
- 'Test that git rm --cached foo fails if the index matches neither the file nor HEAD' '
53
- echo content >foo &&
54
- git add foo &&
55
- git commit -m foo --allow-empty &&
56
- echo "other content" >foo &&
57
- git add foo &&
58
- echo "yet another content" >foo &&
59
- test_must_fail git rm --cached foo
60
-'
61
-
62
-test_expect_success \
63
- 'Test that git rm --cached -f foo works in case where --cached only did not' \
64
- 'echo content >foo &&
65
- git add foo &&
66
- git commit -m foo --allow-empty &&
67
- echo "other content" >foo &&
68
- git add foo &&
69
- echo "yet another content" >foo &&
70
- git rm --cached -f foo'
71
-
72
-test_expect_success \
73
- 'Post-check that foo exists but is not in index after git rm foo' \
74
- '[ -f foo ] && test_must_fail git ls-files --error-unmatch foo'
75
-
76
-test_expect_success \
77
- 'Pre-check that bar exists and is in index before "git rm bar"' \
78
- '[ -f bar ] && git ls-files --error-unmatch bar'
79
-
80
-test_expect_success \
81
- 'Test that "git rm bar" succeeds' \
82
- 'git rm bar'
83
-
84
-test_expect_success \
85
- 'Post-check that bar does not exist and is not in index after "git rm -f bar"' \
86
- '! [ -f bar ] && test_must_fail git ls-files --error-unmatch bar'
87
-
88
-test_expect_success \
89
- 'Test that "git rm -- -q" succeeds (remove a file that looks like an option)' \
90
- 'git rm -- -q'
91
-
92
-test_expect_success FUNNYNAMES \
93
- "Test that \"git rm -f\" succeeds with embedded space, tab, or newline characters." \
94
- "git rm -f 'space embedded' 'tab embedded' 'newline
95
-embedded'"
22
+test_expect_success FUNNYNAMES 'add files with funny names' '
23
+ touch -- "tab embedded" "newline${LF}embedded" &&
24
+ git add -- "tab embedded" "newline${LF}embedded" &&
25
+ git commit -m "add files with tabs and newlines"
26
+'
27
+
28
+test_expect_success 'Pre-check that foo exists and is in index before git rm foo' '
29
+ test -f foo &&
30
+ git ls-files --error-unmatch foo
31
+'
32
+
33
+test_expect_success 'Test that git rm foo succeeds' '
34
+ git rm --cached foo
35
+'
36
+
37
+test_expect_success 'Test that git rm --cached foo succeeds if the index matches the file' '
38
+ echo content >foo &&
39
+ git add foo &&
40
+ git rm --cached foo
41
+'
42
+
43
+test_expect_success 'Test that git rm --cached foo succeeds if the index matches the file' '
44
+ echo content >foo &&
45
+ git add foo &&
46
+ git commit -m foo &&
47
+ echo "other content" >foo &&
48
+ git rm --cached foo
49
+'
50
+
51
+test_expect_success 'Test that git rm --cached foo fails if the index matches neither the file nor HEAD' '
52
+ echo content >foo &&
53
+ git add foo &&
54
+ git commit -m foo --allow-empty &&
55
+ echo "other content" >foo &&
56
+ git add foo &&
57
+ echo "yet another content" >foo &&
58
+ test_must_fail git rm --cached foo
59
+'
60
+
61
+test_expect_success 'Test that git rm --cached -f foo works in case where --cached only did not' '
62
+ echo content >foo &&
63
+ git add foo &&
64
+ git commit -m foo --allow-empty &&
65
+ echo "other content" >foo &&
66
+ git add foo &&
67
+ echo "yet another content" >foo &&
68
+ git rm --cached -f foo
69
+'
70
+
71
+test_expect_success 'Post-check that foo exists but is not in index after git rm foo' '
72
+ test -f foo &&
73
+ test_must_fail git ls-files --error-unmatch foo
74
+'
75
+
76
+test_expect_success 'Pre-check that bar exists and is in index before "git rm bar"' '
77
+ test -f bar &&
78
+ git ls-files --error-unmatch bar
79
+'
80
+
81
+test_expect_success 'Test that "git rm bar" succeeds' '
82
+ git rm bar
83
+'
84
+
85
+test_expect_success 'Post-check that bar does not exist and is not in index after "git rm -f bar"' '
86
+ ! test -f bar &&
87
+ test_must_fail git ls-files --error-unmatch bar
88
+'
89
+
90
+test_expect_success 'Test that "git rm -- -q" succeeds (remove a file that looks like an option)' '
91
+ git rm -- -q
92
+'
93
+
94
+test_expect_success FUNNYNAMES 'Test that "git rm -f" succeeds with embedded space, tab, or newline characters.' '
95
+ git rm -f "space embedded" "tab embedded" "newline${LF}embedded"
96
+'
97
98
test_expect_success SANITY 'Test that "git rm -f" fails if its rm fails' '
99
test_when_finished "chmod 775 ." &&
@@ -100,9 +101,9 @@ test_expect_success SANITY 'Test that "git rm -f" fails if its rm fails' '
101
test_must_fail git rm -f baz
102
'
103
103
-test_expect_success \
104
- 'When the rm in "git rm -f" fails, it should not remove the file from the index' \
105
- 'git ls-files --error-unmatch baz'
104
+test_expect_success 'When the rm in "git rm -f" fails, it should not remove the file from the index' '
105
+ git ls-files --error-unmatch baz
106
+'
107
108
test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
109
git rm --ignore-unmatch nonexistent
@@ -217,23 +218,25 @@ test_expect_success 'Remove nonexistent file returns nonzero exit status' '
218
219
test_expect_success 'Call "rm" from outside the work tree' '
220
mkdir repo &&
220
- (cd repo &&
221
- git init &&
222
- echo something >somefile &&
223
- git add somefile &&
224
- git commit -m "add a file" &&
225
- (cd .. &&
226
- git --git-dir=repo/.git --work-tree=repo rm somefile) &&
227
- test_must_fail git ls-files --error-unmatch somefile)
221
+ (
222
+ cd repo &&
223
+ git init &&
224
+ echo something >somefile &&
225
+ git add somefile &&
226
+ git commit -m "add a file" &&
227
+ (
228
+ cd .. &&
229
+ git --git-dir=repo/.git --work-tree=repo rm somefile
230
+ ) &&
231
+ test_must_fail git ls-files --error-unmatch somefile
232
+ )
233
'
234
235
test_expect_success 'refresh index before checking if it is up-to-date' '
231
-
236
git reset --hard &&
237
test-tool chmtime -86400 frotz/nitfol &&
238
git rm frotz/nitfol &&
239
test ! -f frotz/nitfol
236
-
240
'
241
242
test_expect_success 'choking "git rm" should not let it die with cruft' '
@@ -242,8 +245,8 @@ test_expect_success 'choking "git rm" should not let it die with cruft' '
245
i=0 &&
246
while test $i -lt 12000
247
do
245
- echo "100644 1234567890123456789012345678901234567890 0 some-file-$i"
246
- i=$(( $i + 1 ))
248
+ echo "100644 1234567890123456789012345678901234567890 0 some-file-$i"
249
+ i=$(( $i + 1 ))
250
done | git update-index --index-info &&
251
git rm -n "some-file-*" | : &&
252
test_path_is_missing .git/index.lock
@@ -545,7 +548,8 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
548
git checkout conflict1 &&
549
git reset --hard &&
550
git submodule update &&
548
- (cd submod &&
551
+ (
552
+ cd submod &&
553
rm .git &&
554
cp -R ../.git/modules/sub .git &&
555
GIT_WORK_TREE=. git config --unset core.worktree
@@ -579,7 +583,8 @@ test_expect_success 'rm of a populated submodule with a .git directory migrates
583
git checkout -f master &&
584
git reset --hard &&
585
git submodule update &&
582
- (cd submod &&
586
+ (
587
+ cd submod &&
588
rm .git &&
589
cp -R ../.git/modules/sub .git &&
590
GIT_WORK_TREE=. git config --unset core.worktree &&
@@ -600,7 +605,8 @@ EOF
605
test_expect_success 'setup subsubmodule' '
606
git reset --hard &&
607
git submodule update &&
603
- (cd submod &&
608
+ (
609
+ cd submod &&
610
git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) subsubmod &&
611
git config -f .gitmodules submodule.sub.url ../. &&
612
git config -f .gitmodules submodule.sub.path subsubmod &&
@@ -667,7 +673,8 @@ test_expect_success 'rm of a populated nested submodule with nested untracked fi
673
test_expect_success "rm absorbs submodule's nested .git directory" '
674
git reset --hard &&
675
git submodule update --recursive &&
670
- (cd submod/subsubmod &&
676
+ (
677
+ cd submod/subsubmod &&
678
rm .git &&
679
mv ../../.git/modules/sub/modules/sub .git &&
680
GIT_WORK_TREE=. git config --unset core.worktree