|
3 | 3 | test_description='git mv in subdirs'
|
4 | 4 | . ./test-lib.sh
|
5 | 5 |
|
6 |
| -test_expect_success \ |
7 |
| - 'prepare reference tree' \ |
8 |
| - 'mkdir path0 path1 && |
| 6 | +test_expect_success 'prepare reference tree' ' |
| 7 | + mkdir path0 path1 && |
9 | 8 | cp "$TEST_DIRECTORY"/../COPYING path0/COPYING &&
|
10 | 9 | git add path0/COPYING &&
|
11 |
| - git commit -m add -a' |
| 10 | + git commit -m add -a |
| 11 | +' |
12 | 12 |
|
13 |
| -test_expect_success \ |
14 |
| - 'moving the file out of subdirectory' \ |
15 |
| - 'cd path0 && git mv COPYING ../path1/COPYING' |
| 13 | +test_expect_success 'moving the file out of subdirectory' ' |
| 14 | + cd path0 && git mv COPYING ../path1/COPYING |
| 15 | +' |
16 | 16 |
|
17 | 17 | # in path0 currently
|
18 |
| -test_expect_success \ |
19 |
| - 'commiting the change' \ |
20 |
| - 'cd .. && git commit -m move-out -a' |
| 18 | +test_expect_success 'commiting the change' ' |
| 19 | + cd .. && git commit -m move-out -a |
| 20 | +' |
21 | 21 |
|
22 |
| -test_expect_success \ |
23 |
| - 'checking the commit' \ |
24 |
| - 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
25 |
| - grep "^R100..*path0/COPYING..*path1/COPYING" actual' |
| 22 | +test_expect_success 'checking the commit' ' |
| 23 | + git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
| 24 | + grep "^R100..*path0/COPYING..*path1/COPYING" actual |
| 25 | +' |
26 | 26 |
|
27 |
| -test_expect_success \ |
28 |
| - 'moving the file back into subdirectory' \ |
29 |
| - 'cd path0 && git mv ../path1/COPYING COPYING' |
| 27 | +test_expect_success 'moving the file back into subdirectory' ' |
| 28 | + cd path0 && git mv ../path1/COPYING COPYING |
| 29 | +' |
30 | 30 |
|
31 | 31 | # in path0 currently
|
32 |
| -test_expect_success \ |
33 |
| - 'commiting the change' \ |
34 |
| - 'cd .. && git commit -m move-in -a' |
35 |
| - |
36 |
| -test_expect_success \ |
37 |
| - 'checking the commit' \ |
38 |
| - 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
39 |
| - grep "^R100..*path1/COPYING..*path0/COPYING" actual' |
40 |
| - |
41 |
| -test_expect_success \ |
42 |
| - 'mv --dry-run does not move file' \ |
43 |
| - 'git mv -n path0/COPYING MOVED && |
| 32 | +test_expect_success 'commiting the change' ' |
| 33 | + cd .. && git commit -m move-in -a |
| 34 | +' |
| 35 | + |
| 36 | +test_expect_success 'checking the commit' ' |
| 37 | + git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
| 38 | + grep "^R100..*path1/COPYING..*path0/COPYING" actual |
| 39 | +' |
| 40 | + |
| 41 | +test_expect_success 'mv --dry-run does not move file' ' |
| 42 | + git mv -n path0/COPYING MOVED && |
44 | 43 | test -f path0/COPYING &&
|
45 |
| - test ! -f MOVED' |
| 44 | + test ! -f MOVED |
| 45 | +' |
46 | 46 |
|
47 |
| -test_expect_success \ |
48 |
| - 'checking -k on non-existing file' \ |
49 |
| - 'git mv -k idontexist path0' |
| 47 | +test_expect_success 'checking -k on non-existing file' ' |
| 48 | + git mv -k idontexist path0 |
| 49 | +' |
50 | 50 |
|
51 |
| -test_expect_success \ |
52 |
| - 'checking -k on untracked file' \ |
53 |
| - 'touch untracked1 && |
| 51 | +test_expect_success 'checking -k on untracked file' ' |
| 52 | + touch untracked1 && |
54 | 53 | git mv -k untracked1 path0 &&
|
55 | 54 | test -f untracked1 &&
|
56 |
| - test ! -f path0/untracked1' |
| 55 | + test ! -f path0/untracked1 |
| 56 | +' |
57 | 57 |
|
58 |
| -test_expect_success \ |
59 |
| - 'checking -k on multiple untracked files' \ |
60 |
| - 'touch untracked2 && |
| 58 | +test_expect_success 'checking -k on multiple untracked files' ' |
| 59 | + touch untracked2 && |
61 | 60 | git mv -k untracked1 untracked2 path0 &&
|
62 | 61 | test -f untracked1 &&
|
63 | 62 | test -f untracked2 &&
|
64 | 63 | test ! -f path0/untracked1 &&
|
65 |
| - test ! -f path0/untracked2' |
| 64 | + test ! -f path0/untracked2 |
| 65 | +' |
66 | 66 |
|
67 |
| -test_expect_success \ |
68 |
| - 'checking -f on untracked file with existing target' \ |
69 |
| - 'touch path0/untracked1 && |
| 67 | +test_expect_success 'checking -f on untracked file with existing target' ' |
| 68 | + touch path0/untracked1 && |
70 | 69 | test_must_fail git mv -f untracked1 path0 &&
|
71 | 70 | test ! -f .git/index.lock &&
|
72 | 71 | test -f untracked1 &&
|
73 |
| - test -f path0/untracked1' |
| 72 | + test -f path0/untracked1 |
| 73 | +' |
74 | 74 |
|
75 | 75 | # clean up the mess in case bad things happen
|
76 | 76 | rm -f idontexist untracked1 untracked2 \
|
77 | 77 | path0/idontexist path0/untracked1 path0/untracked2 \
|
78 | 78 | .git/index.lock
|
79 | 79 | rmdir path1
|
80 | 80 |
|
81 |
| -test_expect_success \ |
82 |
| - 'moving to absent target with trailing slash' \ |
83 |
| - 'test_must_fail git mv path0/COPYING no-such-dir/ && |
| 81 | +test_expect_success 'moving to absent target with trailing slash' ' |
| 82 | + test_must_fail git mv path0/COPYING no-such-dir/ && |
84 | 83 | test_must_fail git mv path0/COPYING no-such-dir// &&
|
85 | 84 | git mv path0/ no-such-dir/ &&
|
86 |
| - test_path_is_dir no-such-dir' |
| 85 | + test_path_is_dir no-such-dir |
| 86 | +' |
87 | 87 |
|
88 |
| -test_expect_success \ |
89 |
| - 'clean up' \ |
90 |
| - 'git reset --hard' |
| 88 | +test_expect_success 'clean up' ' |
| 89 | + git reset --hard |
| 90 | +' |
91 | 91 |
|
92 |
| -test_expect_success \ |
93 |
| - 'moving to existing untracked target with trailing slash' \ |
94 |
| - 'mkdir path1 && |
| 92 | +test_expect_success 'moving to existing untracked target with trailing slash' ' |
| 93 | + mkdir path1 && |
95 | 94 | git mv path0/ path1/ &&
|
96 |
| - test_path_is_dir path1/path0/' |
| 95 | + test_path_is_dir path1/path0/ |
| 96 | +' |
97 | 97 |
|
98 |
| -test_expect_success \ |
99 |
| - 'moving to existing tracked target with trailing slash' \ |
100 |
| - 'mkdir path2 && |
| 98 | +test_expect_success 'moving to existing tracked target with trailing slash' ' |
| 99 | + mkdir path2 && |
101 | 100 | >path2/file && git add path2/file &&
|
102 | 101 | git mv path1/path0/ path2/ &&
|
103 |
| - test_path_is_dir path2/path0/' |
| 102 | + test_path_is_dir path2/path0/ |
| 103 | +' |
104 | 104 |
|
105 |
| -test_expect_success \ |
106 |
| - 'clean up' \ |
107 |
| - 'git reset --hard' |
| 105 | +test_expect_success 'clean up' ' |
| 106 | + git reset --hard |
| 107 | +' |
108 | 108 |
|
109 |
| -test_expect_success \ |
110 |
| - 'adding another file' \ |
111 |
| - 'cp "$TEST_DIRECTORY"/../README.md path0/README && |
| 109 | +test_expect_success 'adding another file' ' |
| 110 | + cp "$TEST_DIRECTORY"/../README.md path0/README && |
112 | 111 | git add path0/README &&
|
113 |
| - git commit -m add2 -a' |
| 112 | + git commit -m add2 -a |
| 113 | +' |
114 | 114 |
|
115 |
| -test_expect_success \ |
116 |
| - 'moving whole subdirectory' \ |
117 |
| - 'git mv path0 path2' |
| 115 | +test_expect_success 'moving whole subdirectory' ' |
| 116 | + git mv path0 path2 |
| 117 | +' |
118 | 118 |
|
119 |
| -test_expect_success \ |
120 |
| - 'commiting the change' \ |
121 |
| - 'git commit -m dir-move -a' |
| 119 | +test_expect_success 'commiting the change' ' |
| 120 | + git commit -m dir-move -a |
| 121 | +' |
122 | 122 |
|
123 |
| -test_expect_success \ |
124 |
| - 'checking the commit' \ |
125 |
| - 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
| 123 | +test_expect_success 'checking the commit' ' |
| 124 | + git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
126 | 125 | grep "^R100..*path0/COPYING..*path2/COPYING" actual &&
|
127 |
| - grep "^R100..*path0/README..*path2/README" actual' |
| 126 | + grep "^R100..*path0/README..*path2/README" actual |
| 127 | +' |
128 | 128 |
|
129 |
| -test_expect_success \ |
130 |
| - 'succeed when source is a prefix of destination' \ |
131 |
| - 'git mv path2/COPYING path2/COPYING-renamed' |
| 129 | +test_expect_success 'succeed when source is a prefix of destination' ' |
| 130 | + git mv path2/COPYING path2/COPYING-renamed |
| 131 | +' |
132 | 132 |
|
133 |
| -test_expect_success \ |
134 |
| - 'moving whole subdirectory into subdirectory' \ |
135 |
| - 'git mv path2 path1' |
| 133 | +test_expect_success 'moving whole subdirectory into subdirectory' ' |
| 134 | + git mv path2 path1 |
| 135 | +' |
136 | 136 |
|
137 |
| -test_expect_success \ |
138 |
| - 'commiting the change' \ |
139 |
| - 'git commit -m dir-move -a' |
| 137 | +test_expect_success 'commiting the change' ' |
| 138 | + git commit -m dir-move -a |
| 139 | +' |
140 | 140 |
|
141 |
| -test_expect_success \ |
142 |
| - 'checking the commit' \ |
143 |
| - 'git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
| 141 | +test_expect_success 'checking the commit' ' |
| 142 | + git diff-tree -r -M --name-status HEAD^ HEAD >actual && |
144 | 143 | grep "^R100..*path2/COPYING..*path1/path2/COPYING" actual &&
|
145 |
| - grep "^R100..*path2/README..*path1/path2/README" actual' |
| 144 | + grep "^R100..*path2/README..*path1/path2/README" actual |
| 145 | +' |
146 | 146 |
|
147 |
| -test_expect_success \ |
148 |
| - 'do not move directory over existing directory' \ |
149 |
| - 'mkdir path0 && mkdir path0/path2 && test_must_fail git mv path2 path0' |
| 147 | +test_expect_success 'do not move directory over existing directory' ' |
| 148 | + mkdir path0 && mkdir path0/path2 && test_must_fail git mv path2 path0 |
| 149 | +' |
150 | 150 |
|
151 |
| -test_expect_success \ |
152 |
| - 'move into "."' \ |
153 |
| - 'git mv path1/path2/ .' |
| 151 | +test_expect_success 'move into "."' ' |
| 152 | + git mv path1/path2/ . |
| 153 | +' |
154 | 154 |
|
155 | 155 | test_expect_success "Michael Cassar's test case" '
|
156 | 156 | rm -fr .git papers partA &&
|
|
0 commit comments