@@ -241,4 +241,109 @@ test_expect_success 'Spill with modified spillable file' '
241
241
stg undo --hard
242
242
'
243
243
244
+ cat > expected-status.txt << EOF
245
+ A dir0/dir1/new.txt
246
+ EOF
247
+ cat > expected-files.txt << EOF
248
+ M dir0/a.txt
249
+ M dir0/dir1/e.txt
250
+ EOF
251
+ test_expect_success ' Spill patch with just-added files' '
252
+ echo "new file" > dir0/dir1/new.txt &&
253
+ stg add dir0/dir1/new.txt &&
254
+ echo "modification" >> dir0/a.txt &&
255
+ echo "modification" >> dir0/dir1/e.txt &&
256
+ stg add dir0 &&
257
+ stg new --refresh -m add-new &&
258
+ (
259
+ cd dir0 &&
260
+ stg spill dir1/new.txt
261
+ ) &&
262
+ stg status > status.txt &&
263
+ test_cmp expected-status.txt status.txt &&
264
+ stg files > files.txt &&
265
+ test_cmp expected-files.txt files.txt &&
266
+ grep "modification" dir0/a.txt &&
267
+ grep "modification" dir0/dir1/e.txt &&
268
+ stg undo --hard &&
269
+ stg delete --top
270
+ '
271
+
272
+ cat > expected-status.txt << EOF
273
+ ?? dir0/dir1/new.txt
274
+ EOF
275
+ cat > expected-files.txt << EOF
276
+ M dir0/a.txt
277
+ M dir0/dir1/e.txt
278
+ EOF
279
+ test_expect_success ' Spill and reset patch with just-added files' '
280
+ echo "new file" > dir0/dir1/new.txt &&
281
+ stg add dir0/dir1/new.txt &&
282
+ echo "modification" >> dir0/a.txt &&
283
+ echo "modification" >> dir0/dir1/e.txt &&
284
+ stg add dir0 &&
285
+ stg new --refresh -m add-new &&
286
+ (
287
+ cd dir0 &&
288
+ stg spill --reset dir1/new.txt
289
+ ) &&
290
+ stg status > status.txt &&
291
+ test_cmp expected-status.txt status.txt &&
292
+ stg files > files.txt &&
293
+ test_cmp expected-files.txt files.txt &&
294
+ grep "modification" dir0/a.txt &&
295
+ grep "modification" dir0/dir1/e.txt &&
296
+ stg undo --hard &&
297
+ stg delete --top
298
+ '
299
+
300
+ cat > expected-status.txt << EOF
301
+ M dir0/dir1/e.txt
302
+ A dir0/dir1/new.txt
303
+ EOF
304
+ cat > expected-files.txt << EOF
305
+ M dir0/a.txt
306
+ EOF
307
+ test_expect_success ' Spill patch with just-added files in wildcard dir' '
308
+ echo "new file" > dir0/dir1/new.txt &&
309
+ stg add dir0/dir1/new.txt &&
310
+ echo "modification" >> dir0/a.txt &&
311
+ echo "modification" >> dir0/dir1/e.txt &&
312
+ stg add dir0 &&
313
+ stg new --refresh -m add-new &&
314
+ (
315
+ cd dir0 &&
316
+ stg spill dir1
317
+ ) &&
318
+ stg status > status.txt &&
319
+ test_cmp expected-status.txt status.txt &&
320
+ stg files > files.txt &&
321
+ test_cmp expected-files.txt files.txt &&
322
+ grep "modification" dir0/a.txt &&
323
+ grep "modification" dir0/dir1/e.txt &&
324
+ stg undo --hard &&
325
+ stg delete --top
326
+ '
327
+
328
+ cat > expected-status.txt << EOF
329
+ D dir0/dir1/e.txt
330
+ EOF
331
+ cat > expected-files.txt << EOF
332
+ M dir0/a.txt
333
+ EOF
334
+ test_expect_success ' Spill removed file' '
335
+ echo "modification" >> dir0/a.txt &&
336
+ stg add dir0/a.txt &&
337
+ stg rm dir0/dir1/e.txt &&
338
+ stg new -rm rm-file &&
339
+ stg spill dir0/dir1 &&
340
+ stg status > status.txt &&
341
+ test_cmp expected-status.txt status.txt &&
342
+ stg files > files.txt &&
343
+ test_cmp expected-files.txt files.txt &&
344
+ grep "modification" dir0/a.txt &&
345
+ stg undo --hard &&
346
+ stg delete --top
347
+ '
348
+
244
349
test_done
0 commit comments