Skip to content

Commit b5368c2

Browse files
r1walzgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 21d5ad9 commit b5368c2

File tree

1 file changed

+107
-100
lines changed

1 file changed

+107
-100
lines changed

t/t3600-rm.sh

Lines changed: 107 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -8,101 +8,102 @@ test_description='Test of the various options to git rm.'
88
. ./test-lib.sh
99

1010
# 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+
'
1616

17-
if test_have_prereq !FUNNYNAMES; then
17+
if test_have_prereq !FUNNYNAMES
18+
then
1819
say 'Your filesystem does not allow tabs in filenames.'
1920
fi
2021

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+
'
9697

9798
test_expect_success SANITY 'Test that "git rm -f" fails if its rm fails' '
9899
test_when_finished "chmod 775 ." &&
99100
chmod a-w . &&
100101
test_must_fail git rm -f baz
101102
'
102103

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+
'
106107

107108
test_expect_success 'Remove nonexistent file with --ignore-unmatch' '
108109
git rm --ignore-unmatch nonexistent
@@ -217,23 +218,25 @@ test_expect_success 'Remove nonexistent file returns nonzero exit status' '
217218

218219
test_expect_success 'Call "rm" from outside the work tree' '
219220
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+
)
228233
'
229234

230235
test_expect_success 'refresh index before checking if it is up-to-date' '
231-
232236
git reset --hard &&
233237
test-tool chmtime -86400 frotz/nitfol &&
234238
git rm frotz/nitfol &&
235239
test ! -f frotz/nitfol
236-
237240
'
238241

239242
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' '
242245
i=0 &&
243246
while test $i -lt 12000
244247
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 ))
247250
done | git update-index --index-info &&
248251
git rm -n "some-file-*" | : &&
249252
test_path_is_missing .git/index.lock
@@ -545,7 +548,8 @@ test_expect_success 'rm of a conflicted populated submodule with a .git director
545548
git checkout conflict1 &&
546549
git reset --hard &&
547550
git submodule update &&
548-
(cd submod &&
551+
(
552+
cd submod &&
549553
rm .git &&
550554
cp -R ../.git/modules/sub .git &&
551555
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
579583
git checkout -f master &&
580584
git reset --hard &&
581585
git submodule update &&
582-
(cd submod &&
586+
(
587+
cd submod &&
583588
rm .git &&
584589
cp -R ../.git/modules/sub .git &&
585590
GIT_WORK_TREE=. git config --unset core.worktree &&
@@ -600,7 +605,8 @@ EOF
600605
test_expect_success 'setup subsubmodule' '
601606
git reset --hard &&
602607
git submodule update &&
603-
(cd submod &&
608+
(
609+
cd submod &&
604610
git update-index --add --cacheinfo 160000 $(git rev-parse HEAD) subsubmod &&
605611
git config -f .gitmodules submodule.sub.url ../. &&
606612
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
667673
test_expect_success "rm absorbs submodule's nested .git directory" '
668674
git reset --hard &&
669675
git submodule update --recursive &&
670-
(cd submod/subsubmod &&
676+
(
677+
cd submod/subsubmod &&
671678
rm .git &&
672679
mv ../../.git/modules/sub/modules/sub .git &&
673680
GIT_WORK_TREE=. git config --unset core.worktree

0 commit comments

Comments
 (0)