@@ -4,6 +4,11 @@ test_description='git mv in subdirs'
4
4
. ./test-lib.sh
5
5
. " $TEST_DIRECTORY " /lib-diff-data.sh
6
6
7
+ index_at_path () {
8
+ entry=$( git ls-files --stage " $@ " ) &&
9
+ echo " $entry " | cut -f 1
10
+ }
11
+
7
12
test_expect_success ' mv -f refreshes updated index entry' '
8
13
echo test >bar &&
9
14
git add bar &&
@@ -187,7 +192,8 @@ test_expect_success "Michael Cassar's test case" '
187
192
git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf &&
188
193
189
194
T=$(git write-tree) &&
190
- git ls-tree -r $T | verbose grep partA/outline.txt
195
+ git ls-tree -r $T >out &&
196
+ verbose grep partA/outline.txt out
191
197
'
192
198
193
199
rm -fr papers partA path?
@@ -260,12 +266,12 @@ test_expect_success 'git mv should not change sha1 of moved cache entry' '
260
266
git init &&
261
267
echo 1 >dirty &&
262
268
git add dirty &&
263
- entry="$(git ls-files --stage dirty | cut -f 1 )" &&
269
+ entry="$(index_at_path dirty)" &&
264
270
git mv dirty dirty2 &&
265
- test "$entry" = "$(git ls-files --stage dirty2 | cut -f 1 )" &&
271
+ test "$entry" = "$(index_at_path dirty2)" &&
266
272
echo 2 >dirty2 &&
267
273
git mv dirty2 dirty &&
268
- test "$entry" = "$(git ls-files --stage dirty | cut -f 1 )"
274
+ test "$entry" = "$(index_at_path dirty)"
269
275
'
270
276
271
277
rm -f dirty dirty2
@@ -342,7 +348,7 @@ test_expect_success 'git mv cannot move a submodule in a file' '
342
348
'
343
349
344
350
test_expect_success ' git mv moves a submodule with a .git directory and no .gitmodules' '
345
- entry="$(git ls-files --stage sub | cut -f 1 )" &&
351
+ entry="$(index_at_path sub)" &&
346
352
git rm .gitmodules &&
347
353
(
348
354
cd sub &&
@@ -353,7 +359,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and no .gitm
353
359
mkdir mod &&
354
360
git mv sub mod/sub &&
355
361
test_path_is_missing sub &&
356
- test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1 )" &&
362
+ test "$entry" = "$(index_at_path mod/sub)" &&
357
363
git -C mod/sub status &&
358
364
git update-index --refresh &&
359
365
git diff-files --quiet
@@ -363,7 +369,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu
363
369
rm -rf mod &&
364
370
git reset --hard &&
365
371
git submodule update &&
366
- entry="$(git ls-files --stage sub | cut -f 1 )" &&
372
+ entry="$(index_at_path sub)" &&
367
373
(
368
374
cd sub &&
369
375
rm -f .git &&
@@ -373,7 +379,7 @@ test_expect_success 'git mv moves a submodule with a .git directory and .gitmodu
373
379
mkdir mod &&
374
380
git mv sub mod/sub &&
375
381
test_path_is_missing sub &&
376
- test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1 )" &&
382
+ test "$entry" = "$(index_at_path mod/sub)" &&
377
383
git -C mod/sub status &&
378
384
echo mod/sub >expected &&
379
385
git config -f .gitmodules submodule.sub.path >actual &&
@@ -386,11 +392,11 @@ test_expect_success 'git mv moves a submodule with gitfile' '
386
392
rm -rf mod &&
387
393
git reset --hard &&
388
394
git submodule update &&
389
- entry="$(git ls-files --stage sub | cut -f 1 )" &&
395
+ entry="$(index_at_path sub)" &&
390
396
mkdir mod &&
391
397
git -C mod mv ../sub/ . &&
392
398
test_path_is_missing sub &&
393
- test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1 )" &&
399
+ test "$entry" = "$(index_at_path mod/sub)" &&
394
400
git -C mod/sub status &&
395
401
echo mod/sub >expected &&
396
402
git config -f .gitmodules submodule.sub.path >actual &&
@@ -404,12 +410,12 @@ test_expect_success 'mv does not complain when no .gitmodules file is found' '
404
410
git reset --hard &&
405
411
git submodule update &&
406
412
git rm .gitmodules &&
407
- entry="$(git ls-files --stage sub | cut -f 1 )" &&
413
+ entry="$(index_at_path sub)" &&
408
414
mkdir mod &&
409
415
git mv sub mod/sub 2>actual.err &&
410
416
test_must_be_empty actual.err &&
411
417
test_path_is_missing sub &&
412
- test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1 )" &&
418
+ test "$entry" = "$(index_at_path mod/sub)" &&
413
419
git -C mod/sub status &&
414
420
git update-index --refresh &&
415
421
git diff-files --quiet
@@ -420,7 +426,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta
420
426
git reset --hard &&
421
427
git submodule update &&
422
428
git config -f .gitmodules foo.bar true &&
423
- entry="$(git ls-files --stage sub | cut -f 1 )" &&
429
+ entry="$(index_at_path sub)" &&
424
430
mkdir mod &&
425
431
test_must_fail git mv sub mod/sub 2>actual.err &&
426
432
test_file_not_empty actual.err &&
@@ -430,7 +436,7 @@ test_expect_success 'mv will error out on a modified .gitmodules file unless sta
430
436
git mv sub mod/sub 2>actual.err &&
431
437
test_must_be_empty actual.err &&
432
438
test_path_is_missing sub &&
433
- test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1 )" &&
439
+ test "$entry" = "$(index_at_path mod/sub)" &&
434
440
git -C mod/sub status &&
435
441
git update-index --refresh &&
436
442
git diff-files --quiet
@@ -442,13 +448,13 @@ test_expect_success 'mv issues a warning when section is not found in .gitmodule
442
448
git submodule update &&
443
449
git config -f .gitmodules --remove-section submodule.sub &&
444
450
git add .gitmodules &&
445
- entry="$(git ls-files --stage sub | cut -f 1 )" &&
451
+ entry="$(index_at_path sub)" &&
446
452
echo "warning: Could not find section in .gitmodules where path=sub" >expect.err &&
447
453
mkdir mod &&
448
454
git mv sub mod/sub 2>actual.err &&
449
455
test_cmp expect.err actual.err &&
450
456
test_path_is_missing sub &&
451
- test "$entry" = "$(git ls-files --stage mod/sub | cut -f 1 )" &&
457
+ test "$entry" = "$(index_at_path mod/sub)" &&
452
458
git -C mod/sub status &&
453
459
git update-index --refresh &&
454
460
git diff-files --quiet
0 commit comments