t2000: rename and combine checkout clash tests
In an earlier patch some tests scripts were renamed and a naming convention was documented. [1] Merge t2000-checkout-cache-clash.sh and t2001-checkout-cache-clash.sh into t2000-conflict-when-checking-files-out.sh. [1] f50c9f76c ("Rename some test scripts and describe the naming convention", 2005-05-15) Signed-off-by: Stephen P. Smith <ischis2@cox.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stephen P. Smith committed
Oct 22, 2018 at 20:53 UTC
b684062f889ae71f5887d04788b7c5d2afba720e
3 files changed
+135
-145
t/t2000-checkout-cache-clash.sh
deleted
-60
@@ -1,60 +0,0 @@
1
-#!/bin/sh
2
-#
3
-# Copyright (c) 2005 Junio C Hamano
4
-#
5
-
6
-test_description='git checkout-index test.
7
-
8
-This test registers the following filesystem structure in the
9
-cache:
10
-
11
- path0 - a file
12
- path1/file1 - a file in a directory
13
-
14
-And then tries to checkout in a work tree that has the following:
15
-
16
- path0/file0 - a file in a directory
17
- path1 - a file
18
-
19
-The git checkout-index command should fail when attempting to checkout
20
-path0, finding it is occupied by a directory, and path1/file1, finding
21
-path1 is occupied by a non-directory. With "-f" flag, it should remove
22
-the conflicting paths and succeed.
23
-'
24
-. ./test-lib.sh
25
-
26
-date >path0
27
-mkdir path1
28
-date >path1/file1
29
-
30
-test_expect_success \
31
- 'git update-index --add various paths.' \
32
- 'git update-index --add path0 path1/file1'
33
-
34
-rm -fr path0 path1
35
-mkdir path0
36
-date >path0/file0
37
-date >path1
38
-
39
-test_expect_success \
40
- 'git checkout-index without -f should fail on conflicting work tree.' \
41
- 'test_must_fail git checkout-index -a'
42
-
43
-test_expect_success \
44
- 'git checkout-index with -f should succeed.' \
45
- 'git checkout-index -f -a'
46
-
47
-test_expect_success \
48
- 'git checkout-index conflicting paths.' \
49
- 'test -f path0 && test -d path1 && test -f path1/file1'
50
-
51
-test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' '
52
- mkdir -p tar/get &&
53
- ln -s tar/get there &&
54
- echo first &&
55
- git checkout-index -a -f --prefix=there/ &&
56
- echo second &&
57
- git checkout-index -a -f --prefix=there/
58
-'
59
-
60
-test_done
t/t2000-conflict-when-checking-files-out.sh
new
+135
@@ -0,0 +1,135 @@
1
+#!/bin/sh
2
+#
3
+# Copyright (c) 2005 Junio C Hamano
4
+#
5
+
6
+test_description='git conflicts when checking files out test.'
7
+
8
+# The first test registers the following filesystem structure in the
9
+# cache:
10
+#
11
+# path0 - a file
12
+# path1/file1 - a file in a directory
13
+#
14
+# And then tries to checkout in a work tree that has the following:
15
+#
16
+# path0/file0 - a file in a directory
17
+# path1 - a file
18
+#
19
+# The git checkout-index command should fail when attempting to checkout
20
+# path0, finding it is occupied by a directory, and path1/file1, finding
21
+# path1 is occupied by a non-directory. With "-f" flag, it should remove
22
+# the conflicting paths and succeed.
23
+
24
+. ./test-lib.sh
25
+
26
+show_files() {
27
+ # show filesystem files, just [-dl] for type and name
28
+ find path? -ls |
29
+ sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /'
30
+ # what's in the cache, just mode and name
31
+ git ls-files --stage |
32
+ sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /'
33
+ # what's in the tree, just mode and name.
34
+ git ls-tree -r "$1" |
35
+ sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /'
36
+}
37
+
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
50
+
51
+test_expect_success \
52
+ 'git checkout-index without -f should fail on conflicting work tree.' \
53
+ 'test_must_fail git checkout-index -a'
54
+
55
+test_expect_success \
56
+ 'git checkout-index with -f should succeed.' \
57
+ 'git checkout-index -f -a'
58
+
59
+test_expect_success \
60
+ 'git checkout-index conflicting paths.' \
61
+ 'test -f path0 && test -d path1 && test -f path1/file1'
62
+
63
+test_expect_success SYMLINKS 'checkout-index -f twice with --prefix' '
64
+ mkdir -p tar/get &&
65
+ ln -s tar/get there &&
66
+ echo first &&
67
+ git checkout-index -a -f --prefix=there/ &&
68
+ echo second &&
69
+ git checkout-index -a -f --prefix=there/
70
+'
71
+
72
+# The second test registers the following filesystem structure in the cache:
73
+#
74
+# path2/file0 - a file in a directory
75
+# path3/file1 - a file in a directory
76
+#
77
+# and attempts to check it out when the work tree has:
78
+#
79
+# path2/file0 - a file in a directory
80
+# path3 - a symlink pointing at "path2"
81
+#
82
+# Checkout cache should fail to extract path3/file1 because the leading
83
+# path path3 is occupied by a non-directory. With "-f" it should remove
84
+# the symlink path3 and create directory path3 and file path3/file1.
85
+
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)'
94
+test_debug 'show_files $tree1'
95
+
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)'
104
+test_debug 'show_files $tree2'
105
+
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_debug 'show_files $tree1'
111
+
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_debug 'show_files $tree3'
119
+
120
+# Morten says "Got that?" here.
121
+# Test begins.
122
+
123
+test_expect_success \
124
+ 'read previously written tree and checkout.' \
125
+ 'git read-tree $tree2 && git checkout-index -f -a'
126
+test_debug 'show_files $tree2'
127
+
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'
134
+
135
+test_done
t/t2001-checkout-cache-clash.sh
deleted
-85
@@ -1,85 +0,0 @@
1
-#!/bin/sh
2
-#
3
-# Copyright (c) 2005 Junio C Hamano
4
-#
5
-
6
-test_description='git checkout-index test.
7
-
8
-This test registers the following filesystem structure in the cache:
9
-
10
- path0/file0 - a file in a directory
11
- path1/file1 - a file in a directory
12
-
13
-and attempts to check it out when the work tree has:
14
-
15
- path0/file0 - a file in a directory
16
- path1 - a symlink pointing at "path0"
17
-
18
-Checkout cache should fail to extract path1/file1 because the leading
19
-path path1 is occupied by a non-directory. With "-f" it should remove
20
-the symlink path1 and create directory path1 and file path1/file1.
21
-'
22
-. ./test-lib.sh
23
-
24
-show_files() {
25
- # show filesystem files, just [-dl] for type and name
26
- find path? -ls |
27
- sed -e 's/^[0-9]* * [0-9]* * \([-bcdl]\)[^ ]* *[0-9]* *[^ ]* *[^ ]* *[0-9]* [A-Z][a-z][a-z] [0-9][0-9] [^ ]* /fs: \1 /'
28
- # what's in the cache, just mode and name
29
- git ls-files --stage |
30
- sed -e 's/^\([0-9]*\) [0-9a-f]* [0-3] /ca: \1 /'
31
- # what's in the tree, just mode and name.
32
- git ls-tree -r "$1" |
33
- sed -e 's/^\([0-9]*\) [^ ]* [0-9a-f]* /tr: \1 /'
34
-}
35
-
36
-mkdir path0
37
-date >path0/file0
38
-test_expect_success \
39
- 'git update-index --add path0/file0' \
40
- 'git update-index --add path0/file0'
41
-test_expect_success \
42
- 'writing tree out with git write-tree' \
43
- 'tree1=$(git write-tree)'
44
-test_debug 'show_files $tree1'
45
-
46
-mkdir path1
47
-date >path1/file1
48
-test_expect_success \
49
- 'git update-index --add path1/file1' \
50
- 'git update-index --add path1/file1'
51
-test_expect_success \
52
- 'writing tree out with git write-tree' \
53
- 'tree2=$(git write-tree)'
54
-test_debug 'show_files $tree2'
55
-
56
-rm -fr path1
57
-test_expect_success \
58
- 'read previously written tree and checkout.' \
59
- 'git read-tree -m $tree1 && git checkout-index -f -a'
60
-test_debug 'show_files $tree1'
61
-
62
-test_expect_success \
63
- 'add a symlink' \
64
- 'test_ln_s_add path0 path1'
65
-test_expect_success \
66
- 'writing tree out with git write-tree' \
67
- 'tree3=$(git write-tree)'
68
-test_debug 'show_files $tree3'
69
-
70
-# Morten says "Got that?" here.
71
-# Test begins.
72
-
73
-test_expect_success \
74
- 'read previously written tree and checkout.' \
75
- 'git read-tree $tree2 && git checkout-index -f -a'
76
-test_debug 'show_files $tree2'
77
-
78
-test_expect_success \
79
- 'checking out conflicting path with -f' \
80
- 'test ! -h path0 && test -d path0 &&
81
- test ! -h path1 && test -d path1 &&
82
- test ! -h path0/file0 && test -f path0/file0 &&
83
- test ! -h path1/file1 && test -f path1/file1'
84
-
85
-test_done