t: move tests exercising the "files" backend
We still have a bunch of tests scattered across our test suites that exercise on-disk files of the "files" backend directly: - t1301 exercises permissions of reflog files when the config "core.sharedRepository" is set. - t1400 exercises whether empty directories in the ref store are handled correctly. - t3200 exercises what happens when there are symlinks in the ref store. - t3400 also exercises what happens when ".git/logs" is a symlink. All of these are inherently low-level tests specific to the "files" backend. Move them into "t0600-reffiles-backend.sh" to reflect this. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committed
Feb 15, 2024 at 09:25 UTC
161d9816419796ec5710806a0ee08a3f6359c0eb
5 files changed
+91
-91
t/t0600-reffiles-backend.sh
+91
@@ -381,4 +381,95 @@ test_expect_success 'log diagnoses bogus HEAD symref' '
381
test_grep broken stderr
382
'
383
384
+test_expect_success 'empty directory removal' '
385
+ git branch d1/d2/r1 HEAD &&
386
+ git branch d1/r2 HEAD &&
387
+ test_path_is_file .git/refs/heads/d1/d2/r1 &&
388
+ test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
389
+ git branch -d d1/d2/r1 &&
390
+ test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
391
+ test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
392
+ test_path_is_file .git/refs/heads/d1/r2 &&
393
+ test_path_is_file .git/logs/refs/heads/d1/r2
394
+'
395
+
396
+test_expect_success 'symref empty directory removal' '
397
+ git branch e1/e2/r1 HEAD &&
398
+ git branch e1/r2 HEAD &&
399
+ git checkout e1/e2/r1 &&
400
+ test_when_finished "git checkout main" &&
401
+ test_path_is_file .git/refs/heads/e1/e2/r1 &&
402
+ test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
403
+ git update-ref -d HEAD &&
404
+ test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
405
+ test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
406
+ test_path_is_file .git/refs/heads/e1/r2 &&
407
+ test_path_is_file .git/logs/refs/heads/e1/r2 &&
408
+ test_path_is_file .git/logs/HEAD
409
+'
410
+
411
+test_expect_success 'directory not created deleting packed ref' '
412
+ git branch d1/d2/r1 HEAD &&
413
+ git pack-refs --all &&
414
+ test_path_is_missing .git/refs/heads/d1/d2 &&
415
+ git update-ref -d refs/heads/d1/d2/r1 &&
416
+ test_path_is_missing .git/refs/heads/d1/d2 &&
417
+ test_path_is_missing .git/refs/heads/d1
418
+'
419
+
420
+test_expect_success SYMLINKS 'git branch -m u v should fail when the reflog for u is a symlink' '
421
+ git branch --create-reflog u &&
422
+ mv .git/logs/refs/heads/u real-u &&
423
+ ln -s real-u .git/logs/refs/heads/u &&
424
+ test_must_fail git branch -m u v
425
+'
426
+
427
+test_expect_success SYMLINKS 'git branch -m with symlinked .git/refs' '
428
+ test_when_finished "rm -rf subdir" &&
429
+ git init --bare subdir &&
430
+
431
+ rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
432
+ ln -s ../.git/refs subdir/refs &&
433
+ ln -s ../.git/objects subdir/objects &&
434
+ ln -s ../.git/packed-refs subdir/packed-refs &&
435
+
436
+ git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
437
+ git rev-parse --absolute-git-dir >our.dir &&
438
+ ! test_cmp subdir.dir our.dir &&
439
+
440
+ git -C subdir log &&
441
+ git -C subdir branch rename-src &&
442
+ git rev-parse rename-src >expect &&
443
+ git -C subdir branch -m rename-src rename-dest &&
444
+ git rev-parse rename-dest >actual &&
445
+ test_cmp expect actual &&
446
+ git branch -D rename-dest
447
+'
448
+
449
+test_expect_success MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
450
+ git checkout main &&
451
+ mv .git/logs actual_logs &&
452
+ cmd //c "mklink /D .git\logs ..\actual_logs" &&
453
+ git rebase -f HEAD^ &&
454
+ test -L .git/logs &&
455
+ rm .git/logs &&
456
+ mv actual_logs .git/logs
457
+'
458
+
459
+test_expect_success POSIXPERM 'git reflog expire honors core.sharedRepository' '
460
+ umask 077 &&
461
+ git config core.sharedRepository group &&
462
+ git reflog expire --all &&
463
+ actual="$(ls -l .git/logs/refs/heads/main)" &&
464
+ case "$actual" in
465
+ -rw-rw-*)
466
+ : happy
467
+ ;;
468
+ *)
469
+ echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
470
+ false
471
+ ;;
472
+ esac
473
+'
474
+
475
test_done
t/t1301-shared-repo.sh
-16
@@ -137,22 +137,6 @@ test_expect_success POSIXPERM 'info/refs respects umask in unshared repo' '
137
test_cmp expect actual
138
'
139
140
-test_expect_success REFFILES,POSIXPERM 'git reflog expire honors core.sharedRepository' '
141
- umask 077 &&
142
- git config core.sharedRepository group &&
143
- git reflog expire --all &&
144
- actual="$(ls -l .git/logs/refs/heads/main)" &&
145
- case "$actual" in
146
- -rw-rw-*)
147
- : happy
148
- ;;
149
- *)
150
- echo Ooops, .git/logs/refs/heads/main is not 066x [$actual]
151
- false
152
- ;;
153
- esac
154
-'
155
-
140
test_expect_success POSIXPERM 'forced modes' '
141
test_when_finished "rm -rf new" &&
142
mkdir -p templates/hooks &&
t/t1400-update-ref.sh
-36
@@ -288,33 +288,6 @@ test_expect_success "set $m (logged by touch)" '
288
test $A = $(git show-ref -s --verify $m)
289
'
290
291
-test_expect_success REFFILES 'empty directory removal' '
292
- git branch d1/d2/r1 HEAD &&
293
- git branch d1/r2 HEAD &&
294
- test_path_is_file .git/refs/heads/d1/d2/r1 &&
295
- test_path_is_file .git/logs/refs/heads/d1/d2/r1 &&
296
- git branch -d d1/d2/r1 &&
297
- test_must_fail git show-ref --verify -q refs/heads/d1/d2 &&
298
- test_must_fail git show-ref --verify -q logs/refs/heads/d1/d2 &&
299
- test_path_is_file .git/refs/heads/d1/r2 &&
300
- test_path_is_file .git/logs/refs/heads/d1/r2
301
-'
302
-
303
-test_expect_success REFFILES 'symref empty directory removal' '
304
- git branch e1/e2/r1 HEAD &&
305
- git branch e1/r2 HEAD &&
306
- git checkout e1/e2/r1 &&
307
- test_when_finished "git checkout main" &&
308
- test_path_is_file .git/refs/heads/e1/e2/r1 &&
309
- test_path_is_file .git/logs/refs/heads/e1/e2/r1 &&
310
- git update-ref -d HEAD &&
311
- test_must_fail git show-ref --verify -q refs/heads/e1/e2 &&
312
- test_must_fail git show-ref --verify -q logs/refs/heads/e1/e2 &&
313
- test_path_is_file .git/refs/heads/e1/r2 &&
314
- test_path_is_file .git/logs/refs/heads/e1/r2 &&
315
- test_path_is_file .git/logs/HEAD
316
-'
317
-
291
cat >expect <<EOF
292
$Z $A $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150200 +0000 Initial Creation
293
$A $B $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> 1117150260 +0000 Switch
@@ -1668,13 +1641,4 @@ test_expect_success PIPE 'transaction flushes status updates' '
1641
test_cmp expected actual
1642
'
1643
1671
-test_expect_success REFFILES 'directory not created deleting packed ref' '
1672
- git branch d1/d2/r1 HEAD &&
1673
- git pack-refs --all &&
1674
- test_path_is_missing .git/refs/heads/d1/d2 &&
1675
- git update-ref -d refs/heads/d1/d2/r1 &&
1676
- test_path_is_missing .git/refs/heads/d1/d2 &&
1677
- test_path_is_missing .git/refs/heads/d1
1678
-'
1679
-
1644
test_done
t/t3200-branch.sh
-29
@@ -836,35 +836,6 @@ test_expect_success 'renaming a symref is not allowed' '
836
test_ref_missing refs/heads/new-topic
837
'
838
839
-test_expect_success SYMLINKS,REFFILES 'git branch -m u v should fail when the reflog for u is a symlink' '
840
- git branch --create-reflog u &&
841
- mv .git/logs/refs/heads/u real-u &&
842
- ln -s real-u .git/logs/refs/heads/u &&
843
- test_must_fail git branch -m u v
844
-'
845
-
846
-test_expect_success SYMLINKS,REFFILES 'git branch -m with symlinked .git/refs' '
847
- test_when_finished "rm -rf subdir" &&
848
- git init --bare subdir &&
849
-
850
- rm -rfv subdir/refs subdir/objects subdir/packed-refs &&
851
- ln -s ../.git/refs subdir/refs &&
852
- ln -s ../.git/objects subdir/objects &&
853
- ln -s ../.git/packed-refs subdir/packed-refs &&
854
-
855
- git -C subdir rev-parse --absolute-git-dir >subdir.dir &&
856
- git rev-parse --absolute-git-dir >our.dir &&
857
- ! test_cmp subdir.dir our.dir &&
858
-
859
- git -C subdir log &&
860
- git -C subdir branch rename-src &&
861
- git rev-parse rename-src >expect &&
862
- git -C subdir branch -m rename-src rename-dest &&
863
- git rev-parse rename-dest >actual &&
864
- test_cmp expect actual &&
865
- git branch -D rename-dest
866
-'
867
-
839
test_expect_success 'test tracking setup via --track' '
840
git config remote.local.url . &&
841
git config remote.local.fetch refs/heads/*:refs/remotes/local/* &&
t/t3400-rebase.sh
-10
@@ -424,16 +424,6 @@ test_expect_success 'refuse to switch to branch checked out elsewhere' '
424
test_grep "already used by worktree at" err
425
'
426
427
-test_expect_success REFFILES,MINGW,SYMLINKS_WINDOWS 'rebase when .git/logs is a symlink' '
428
- git checkout main &&
429
- mv .git/logs actual_logs &&
430
- cmd //c "mklink /D .git\logs ..\actual_logs" &&
431
- git rebase -f HEAD^ &&
432
- test -L .git/logs &&
433
- rm .git/logs &&
434
- mv actual_logs .git/logs
435
-'
436
-
427
test_expect_success 'rebase when inside worktree subdirectory' '
428
git init main-wt &&
429
(