@@ -178,6 +178,85 @@ test_expect_success '--paths-from-file' '
178
178
)
179
179
'
180
180
181
+ create_path_filtering_and_renaming () {
182
+ test -d path_filtering_and_renaming && return
183
+
184
+ test_create_repo path_filtering_and_renaming &&
185
+ (
186
+ cd path_filtering_and_renaming &&
187
+
188
+ > .gitignore &&
189
+ mkdir -p src/main/java/com/org/{foo,bar} &&
190
+ mkdir -p src/main/resources &&
191
+ test_seq 1 10 > src/main/java/com/org/foo/uptoten &&
192
+ test_seq 11 20 > src/main/java/com/org/bar/uptotwenty &&
193
+ test_seq 1 7 > src/main/java/com/org/uptoseven &&
194
+ test_seq 1 5 > src/main/resources/uptofive &&
195
+ git add . &&
196
+ git commit -m Initial
197
+ )
198
+ }
199
+
200
+ test_expect_success ' Mixing filtering and renaming paths, not enough filters' '
201
+ create_path_filtering_and_renaming &&
202
+ git clone --no-local path_filtering_and_renaming \
203
+ path_filtering_and_renaming_1 &&
204
+ (
205
+ cd path_filtering_and_renaming_1 &&
206
+
207
+ git filter-repo --path .gitignore \
208
+ --path src/main/resources \
209
+ --path-rename src/main/java/com/org/foo/:src/main/java/com/org/ &&
210
+
211
+ cat <<-EOF >expect &&
212
+ .gitignore
213
+ src/main/resources/uptofive
214
+ EOF
215
+ git ls-files >actual &&
216
+ test_cmp expect actual
217
+ )
218
+ '
219
+
220
+ test_expect_success ' Mixing filtering and renaming paths, enough filters' '
221
+ create_path_filtering_and_renaming &&
222
+ git clone --no-local path_filtering_and_renaming \
223
+ path_filtering_and_renaming_2 &&
224
+ (
225
+ cd path_filtering_and_renaming_2 &&
226
+
227
+ git filter-repo --path .gitignore \
228
+ --path src/main/resources \
229
+ --path src/main/java/com/org/foo/ \
230
+ --path-rename src/main/java/com/org/foo/:src/main/java/com/org/ &&
231
+
232
+ cat <<-EOF >expect &&
233
+ .gitignore
234
+ src/main/java/com/org/uptoten
235
+ src/main/resources/uptofive
236
+ EOF
237
+ git ls-files >actual &&
238
+ test_cmp expect actual
239
+ )
240
+ '
241
+
242
+ test_expect_success ' Mixing filtering and to-subdirectory-filter' '
243
+ create_path_filtering_and_renaming &&
244
+ git clone --no-local path_filtering_and_renaming \
245
+ path_filtering_and_renaming_3 &&
246
+ (
247
+ cd path_filtering_and_renaming_3 &&
248
+
249
+ git filter-repo --path src/main/resources \
250
+ --to-subdirectory-filter my-module &&
251
+
252
+ cat <<-EOF >expect &&
253
+ my-module/src/main/resources/uptofive
254
+ EOF
255
+ git ls-files >actual &&
256
+ test_cmp expect actual
257
+ )
258
+ '
259
+
181
260
test_expect_success ' setup metasyntactic repo' '
182
261
test_create_repo metasyntactic &&
183
262
(
0 commit comments