308
cd mod/sub &&
309
git status
310
) &&
311
+ echo mod/sub >expected &&
312
+ git config -f .gitmodules submodule.sub.path >actual &&
313
+ test_cmp expected actual &&
314
git update-index --refresh &&
315
git diff-files --quiet
316
'
317
318
+test_expect_success 'mv does not complain when no .gitmodules file is found' '
319
+ rm -rf mod/sub &&
320
+ git reset --hard &&
321
+ git submodule update &&
322
+ git rm .gitmodules &&
323
+ entry="$(git ls-files --stage sub | cut -f 1)" &&
324
+ git mv sub mod/sub 2>actual.err &&
325
+ ! test -s actual.err &&
326
+ ! test -e sub &&
327
+ [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] &&
328
+ (
329
+ cd mod/sub &&
330
+ git status
331
+ ) &&
332
+ git update-index --refresh &&
333
+ git diff-files --quiet
334
+'
335
+
336
+test_expect_success 'mv will error out on a modified .gitmodules file unless staged' '
337
+ rm -rf mod/sub &&
338
+ git reset --hard &&
339
+ git submodule update &&
340
+ git config -f .gitmodules foo.bar true &&
341
+ entry="$(git ls-files --stage sub | cut -f 1)" &&
342
+ test_must_fail git mv sub mod/sub 2>actual.err &&
343
+ test -s actual.err &&
344
+ test -e sub &&
345
+ git diff-files --quiet -- sub &&
346
+ git add .gitmodules &&
347
+ git mv sub mod/sub 2>actual.err &&
348
+ ! test -s actual.err &&
349
+ ! test -e sub &&
350
+ [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] &&
351
+ (
352
+ cd mod/sub &&
353
+ git status
354
+ ) &&
355
+ git update-index --refresh &&
356
+ git diff-files --quiet
357
+'
358
+
359
+test_expect_success 'mv issues a warning when section is not found in .gitmodules' '
360
+ rm -rf mod/sub &&
361
+ git reset --hard &&
362
+ git submodule update &&
363
+ git config -f .gitmodules --remove-section submodule.sub &&
364
+ git add .gitmodules &&
365
+ entry="$(git ls-files --stage sub | cut -f 1)" &&
366
+ echo "warning: Could not find section in .gitmodules where path=sub" >expect.err &&
367
+ git mv sub mod/sub 2>actual.err &&
368
+ test_i18ncmp expect.err actual.err &&
369
+ ! test -e sub &&
370
+ [ "$entry" = "$(git ls-files --stage mod/sub | cut -f 1)" ] &&
371
+ (
372
+ cd mod/sub &&
373
+ git status
374
+ ) &&
375
+ git update-index --refresh &&
376
+ git diff-files --quiet
377
+'
378
+
379
+test_expect_success 'mv --dry-run does not touch the submodule or .gitmodules' '
380
+ rm -rf mod/sub &&
381
+ git reset --hard &&
382
+ git submodule update &&
383
+ git mv -n sub mod/sub 2>actual.err &&
384
+ test -f sub/.git &&
385
+ git diff-index --exit-code HEAD &&
386
+ git update-index --refresh &&
387
+ git diff-files --quiet -- sub .gitmodules
388
+'
389
+
390
test_done