Skip to content

Commit 0713d3b

Browse files
committed
Merge branch 'za/t2000-modernise'
Test cleanup. * za/t2000-modernise: t2000: modernise overall structure
2 parents da54784 + d8e34f9 commit 0713d3b

1 file changed

Lines changed: 66 additions & 56 deletions

File tree

t/t2000-conflict-when-checking-files-out.sh

Lines changed: 66 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -35,30 +35,30 @@ show_files() {
3535
sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /'
3636
}
3737

38-
date >path0
39-
mkdir path1
40-
date >path1/file1
41-
42-
test_expect_success \
43-
'git update-index --add various paths.' \
44-
'git update-index --add path0 path1/file1'
45-
46-
rm -fr path0 path1
47-
mkdir path0
48-
date >path0/file0
49-
date >path1
38+
test_expect_success 'prepare files path0 and path1/file1' '
39+
date >path0 &&
40+
mkdir path1 &&
41+
date >path1/file1 &&
42+
git update-index --add path0 path1/file1
43+
'
5044

51-
test_expect_success \
52-
'git checkout-index without -f should fail on conflicting work tree.' \
53-
'test_must_fail git checkout-index -a'
45+
test_expect_success 'prepare working tree files with D/F conflicts' '
46+
rm -fr path0 path1 &&
47+
mkdir path0 &&
48+
date >path0/file0 &&
49+
date >path1
50+
'
5451

55-
test_expect_success \
56-
'git checkout-index with -f should succeed.' \
57-
'git checkout-index -f -a'
52+
test_expect_success 'git checkout-index without -f should fail on conflicting work tree.' '
53+
test_must_fail git checkout-index -a
54+
'
5855

59-
test_expect_success \
60-
'git checkout-index conflicting paths.' \
61-
'test -f path0 && test -d path1 && test -f path1/file1'
56+
test_expect_success 'git checkout-index with -f should succeed.' '
57+
git checkout-index -f -a &&
58+
test_path_is_file path0 &&
59+
test_path_is_dir path1 &&
60+
test_path_is_file path1/file1
61+
'
6262

6363
test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' '
6464
mkdir -p tar/get &&
@@ -83,53 +83,63 @@ test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' '
8383
# path path3 is occupied by a non-directory. With "-f" it should remove
8484
# the symlink path3 and create directory path3 and file path3/file1.
8585

86-
mkdir path2
87-
date >path2/file0
88-
test_expect_success \
89-
'git update-index --add path2/file0' \
90-
'git update-index --add path2/file0'
91-
test_expect_success \
92-
'writing tree out with git write-tree' \
93-
'tree1=$(git write-tree)'
86+
test_expect_success 'prepare path2/file0 and index' '
87+
mkdir path2 &&
88+
date >path2/file0 &&
89+
git update-index --add path2/file0
90+
'
91+
92+
test_expect_success 'write tree with path2/file0' '
93+
tree1=$(git write-tree)
94+
'
95+
9496
test_debug 'show_files $tree1'
9597

96-
mkdir path3
97-
date >path3/file1
98-
test_expect_success \
99-
'git update-index --add path3/file1' \
100-
'git update-index --add path3/file1'
101-
test_expect_success \
102-
'writing tree out with git write-tree' \
103-
'tree2=$(git write-tree)'
98+
test_expect_success 'prepare path3/file1 and index' '
99+
mkdir path3 &&
100+
date >path3/file1 &&
101+
git update-index --add path3/file1
102+
'
103+
104+
test_expect_success 'write tree with path3/file1' '
105+
tree2=$(git write-tree)
106+
'
107+
104108
test_debug 'show_files $tree2'
105109

106-
rm -fr path3
107-
test_expect_success \
108-
'read previously written tree and checkout.' \
109-
'git read-tree -m $tree1 && git checkout-index -f -a'
110+
test_expect_success 'read previously written tree and checkout.' '
111+
rm -fr path3 &&
112+
git read-tree -m $tree1 &&
113+
git checkout-index -f -a
114+
'
115+
110116
test_debug 'show_files $tree1'
111117

112-
test_expect_success \
113-
'add a symlink' \
114-
'test_ln_s_add path2 path3'
115-
test_expect_success \
116-
'writing tree out with git write-tree' \
117-
'tree3=$(git write-tree)'
118+
test_expect_success 'add a symlink' '
119+
test_ln_s_add path2 path3
120+
'
121+
122+
test_expect_success 'write tree with symlink path3' '
123+
tree3=$(git write-tree)
124+
'
125+
118126
test_debug 'show_files $tree3'
119127

120128
# Morten says "Got that?" here.
121129
# Test begins.
122130

123-
test_expect_success \
124-
'read previously written tree and checkout.' \
125-
'git read-tree $tree2 && git checkout-index -f -a'
131+
test_expect_success 'read previously written tree and checkout.' '
132+
git read-tree $tree2 &&
133+
git checkout-index -f -a
134+
'
135+
126136
test_debug 'show_files $tree2'
127137

128-
test_expect_success \
129-
'checking out conflicting path with -f' \
130-
'test ! -h path2 && test -d path2 &&
131-
test ! -h path3 && test -d path3 &&
132-
test ! -h path2/file0 && test -f path2/file0 &&
133-
test ! -h path3/file1 && test -f path3/file1'
138+
test_expect_success 'checking out conflicting path with -f' '
139+
test_path_is_dir_not_symlink path2 &&
140+
test_path_is_dir_not_symlink path3 &&
141+
test_path_is_file_not_symlink path2/file0 &&
142+
test_path_is_file_not_symlink path3/file1
143+
'
134144

135145
test_done

0 commit comments

Comments
 (0)