3 # Copyright (c) 2020 Google LLC
6 test_description
='reftable basics'
7 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
=main
8 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
12 if ! test_have_prereq REFTABLE
14 skip_all
='skipping reftable tests; set GIT_TEST_DEFAULT_REF_FORMAT=reftable'
18 INVALID_OID
=$
(test_oid
001)
20 test_expect_success
'init: creates basic reftable structures' '
21 test_when_finished "rm -rf repo" &&
23 test_path_is_dir repo/.git/reftable &&
24 test_path_is_file repo/.git/reftable/tables.list &&
25 echo reftable >expect &&
26 git -C repo rev-parse --show-ref-format >actual &&
27 test_cmp expect actual
30 test_expect_success
'init: sha256 object format via environment variable' '
31 test_when_finished "rm -rf repo" &&
32 GIT_DEFAULT_HASH=sha256 git init repo &&
37 git -C repo rev-parse --show-object-format --show-ref-format >actual &&
38 test_cmp expect actual
41 test_expect_success
'init: sha256 object format via option' '
42 test_when_finished "rm -rf repo" &&
43 git init --object-format=sha256 repo &&
48 git -C repo rev-parse --show-object-format --show-ref-format >actual &&
49 test_cmp expect actual
52 test_expect_success
'init: reinitializing reftable backend succeeds' '
53 test_when_finished "rm -rf repo" &&
55 test_commit -C repo A &&
57 git -C repo for-each-ref >expect &&
58 git init --ref-format=reftable repo &&
59 git -C repo for-each-ref >actual &&
60 test_cmp expect actual
63 test_expect_success
'init: reinitializing files with reftable backend fails' '
64 test_when_finished "rm -rf repo" &&
65 git init --ref-format=files repo &&
66 test_commit -C repo file &&
68 cp repo/.git/HEAD expect &&
69 test_must_fail git init --ref-format=reftable repo &&
70 test_cmp expect repo/.git/HEAD
73 test_expect_success
'init: reinitializing reftable with files backend fails' '
74 test_when_finished "rm -rf repo" &&
75 git init --ref-format=reftable repo &&
76 test_commit -C repo file &&
78 cp repo/.git/HEAD expect &&
79 test_must_fail git init --ref-format=files repo &&
80 test_cmp expect repo/.git/HEAD
83 test_expect_perms
() {
86 local actual
=$
(ls -l "$file") &&
93 echo "$(basename $2) is not $perms but $actual"
101 test_expect_success POSIXPERM
'init: honors core.sharedRepository' '
102 test_when_finished "rm -rf repo" &&
105 git init --shared=true repo &&
106 test 1 = "$(git -C repo config core.sharedrepository)"
108 test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list &&
109 for table in repo/.git/reftable/*.ref
111 test_expect_perms "-rw-rw-r--" "$table" ||
117 test_expect_success
'clone: can clone reftable repository' '
118 test_when_finished "rm -rf repo clone" &&
120 test_commit -C repo message1 file1 &&
122 git clone repo cloned &&
123 echo reftable >expect &&
124 git -C cloned rev-parse --show-ref-format >actual &&
125 test_cmp expect actual &&
126 test_path_is_file cloned/file1
129 test_expect_success
'clone: can clone reffiles into reftable repository' '
130 test_when_finished "rm -rf reffiles reftable" &&
131 git init --ref-format=files reffiles &&
132 test_commit -C reffiles A &&
133 git clone --ref-format=reftable ./reffiles reftable &&
135 git -C reffiles rev-parse HEAD >expect &&
136 git -C reftable rev-parse HEAD >actual &&
137 test_cmp expect actual &&
139 git -C reftable rev-parse --show-ref-format >actual &&
140 echo reftable >expect &&
141 test_cmp expect actual &&
143 git -C reffiles rev-parse --show-ref-format >actual &&
144 echo files >expect &&
145 test_cmp expect actual
148 test_expect_success
'clone: can clone reftable into reffiles repository' '
149 test_when_finished "rm -rf reffiles reftable" &&
150 git init --ref-format=reftable reftable &&
151 test_commit -C reftable A &&
152 git clone --ref-format=files ./reftable reffiles &&
154 git -C reftable rev-parse HEAD >expect &&
155 git -C reffiles rev-parse HEAD >actual &&
156 test_cmp expect actual &&
158 git -C reftable rev-parse --show-ref-format >actual &&
159 echo reftable >expect &&
160 test_cmp expect actual &&
162 git -C reffiles rev-parse --show-ref-format >actual &&
163 echo files >expect &&
164 test_cmp expect actual
167 test_expect_success
'ref transaction: corrupted tables cause failure' '
168 test_when_finished "rm -rf repo" &&
173 for f in .git/reftable/*.ref
177 test_must_fail git update-ref refs/heads/main HEAD
181 test_expect_success
'ref transaction: corrupted tables.list cause failure' '
182 test_when_finished "rm -rf repo" &&
187 echo garbage >.git/reftable/tables.list &&
188 test_must_fail git update-ref refs/heads/main HEAD
192 test_expect_success
'ref transaction: refuses to write ref causing F/D conflict' '
193 test_when_finished "rm -rf repo" &&
195 test_commit -C repo file &&
196 test_must_fail git -C repo update-ref refs/heads/main/forbidden
199 test_expect_success
'ref transaction: deleting ref with invalid name fails' '
200 test_when_finished "rm -rf repo" &&
202 test_commit -C repo file &&
203 test_must_fail git -C repo update-ref -d ../../my-private-file
206 test_expect_success
'ref transaction: can skip object ID verification' '
207 test_when_finished "rm -rf repo" &&
209 test_must_fail test-tool -C repo ref-store main update-ref msg refs/heads/branch $INVALID_OID $ZERO_OID 0 &&
210 test-tool -C repo ref-store main update-ref msg refs/heads/branch $INVALID_OID $ZERO_OID REF_SKIP_OID_VERIFICATION
213 test_expect_success
'ref transaction: updating same ref multiple times fails' '
214 test_when_finished "rm -rf repo" &&
216 test_commit -C repo A &&
217 cat >updates <<-EOF &&
218 update refs/heads/main $A
219 update refs/heads/main $A
221 cat >expect <<-EOF &&
222 fatal: multiple updates for ref ${SQ}refs/heads/main${SQ} not allowed
224 test_must_fail git -C repo update-ref --stdin <updates 2>err &&
228 test_expect_success
'ref transaction: can delete symbolic self-reference with git-symbolic-ref(1)' '
229 test_when_finished "rm -rf repo" &&
231 git -C repo symbolic-ref refs/heads/self refs/heads/self &&
232 git -C repo symbolic-ref -d refs/heads/self
235 test_expect_success
'ref transaction: deleting symbolic self-reference without --no-deref fails' '
236 test_when_finished "rm -rf repo" &&
238 git -C repo symbolic-ref refs/heads/self refs/heads/self &&
239 cat >expect <<-EOF &&
240 error: multiple updates for ${SQ}refs/heads/self${SQ} (including one via symref ${SQ}refs/heads/self${SQ}) are not allowed
242 test_must_fail git -C repo update-ref -d refs/heads/self 2>err &&
246 test_expect_success
'ref transaction: deleting symbolic self-reference with --no-deref succeeds' '
247 test_when_finished "rm -rf repo" &&
249 git -C repo symbolic-ref refs/heads/self refs/heads/self &&
250 git -C repo update-ref -d --no-deref refs/heads/self
253 test_expect_success
'ref transaction: creating symbolic ref fails with F/D conflict' '
254 test_when_finished "rm -rf repo" &&
256 test_commit -C repo A &&
257 cat >expect <<-EOF &&
258 error: unable to write symref for refs/heads: file/directory conflict
260 test_must_fail git -C repo symbolic-ref refs/heads refs/heads/foo 2>err &&
264 test_expect_success
'ref transaction: ref deletion' '
265 test_when_finished "rm -rf repo" &&
270 HEAD_OID=$(git show-ref -s --verify HEAD) &&
271 cat >expect <<-EOF &&
272 $HEAD_OID refs/heads/main
273 $HEAD_OID refs/tags/file
275 git show-ref >actual &&
276 test_cmp expect actual &&
278 test_must_fail git update-ref -d refs/tags/file $INVALID_OID &&
279 git show-ref >actual &&
280 test_cmp expect actual &&
282 git update-ref -d refs/tags/file $HEAD_OID &&
283 echo "$HEAD_OID refs/heads/main" >expect &&
284 git show-ref >actual &&
285 test_cmp expect actual
289 test_expect_success
'ref transaction: writes cause auto-compaction' '
290 test_when_finished "rm -rf repo" &&
293 test_line_count = 1 repo/.git/reftable/tables.list &&
295 test_commit -C repo --no-tag A &&
296 test_line_count = 2 repo/.git/reftable/tables.list &&
298 test_commit -C repo --no-tag B &&
299 test_line_count = 1 repo/.git/reftable/tables.list
302 check_fsync_events
() {
308 -e '/^{"event":"counter",.*"category":"fsync",/ {
309 s/.*"category":"fsync",//;
314 test_cmp expect actual
317 test_expect_success
'ref transaction: writes are synced' '
318 test_when_finished "rm -rf repo" &&
320 test_commit -C repo initial &&
322 GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
323 GIT_TEST_FSYNC=true \
324 git -C repo -c core.fsync=reference \
325 -c core.fsyncMethod=fsync update-ref refs/heads/branch HEAD &&
326 check_fsync_events trace2.txt <<-EOF
327 "name":"hardware-flush","count":2
331 test_expect_success
'ref transaction: empty transaction in empty repo' '
332 test_when_finished "rm -rf repo" &&
334 test_commit -C repo --no-tag A &&
335 git -C repo update-ref -d refs/heads/main &&
336 test-tool -C repo ref-store main delete-refs REF_NO_DEREF msg HEAD &&
337 git -C repo update-ref --stdin <<-EOF
343 test_expect_success
'ref transaction: fails gracefully when auto compaction fails' '
344 test_when_finished "rm -rf repo" &&
350 for i in $(test_seq 10)
352 git branch branch-$i &&
353 for table in .git/reftable/*.ref
355 touch "$table.lock" || exit 1
359 test_line_count = 13 .git/reftable/tables.list
363 test_expect_success
'pack-refs: compacts tables' '
364 test_when_finished "rm -rf repo" &&
367 test_commit -C repo A &&
368 ls -1 repo/.git/reftable >table-files &&
369 test_line_count = 4 table-files &&
370 test_line_count = 3 repo/.git/reftable/tables.list &&
372 git -C repo pack-refs &&
373 ls -1 repo/.git/reftable >table-files &&
374 test_line_count = 2 table-files &&
375 test_line_count = 1 repo/.git/reftable/tables.list
378 test_expect_success
'pack-refs: compaction raises locking errors' '
379 test_when_finished "rm -rf repo" &&
381 test_commit -C repo A &&
382 touch repo/.git/reftable/tables.list.lock &&
383 cat >expect <<-EOF &&
384 error: unable to compact stack: data is locked
386 test_must_fail git -C repo pack-refs 2>err &&
390 test_expect_success
'pack-refs: prunes stale tables' '
391 test_when_finished "rm -rf repo" &&
393 touch repo/.git/reftable/stale-table.ref &&
394 git -C repo pack-refs &&
395 test_path_is_missing repo/.git/reftable/stable-ref.ref
398 test_expect_success
'pack-refs: does not prune non-table files' '
399 test_when_finished "rm -rf repo" &&
401 touch repo/.git/reftable/garbage &&
402 git -C repo pack-refs &&
403 test_path_is_file repo/.git/reftable/garbage
408 test_expect_success POSIXPERM
'pack-refs: honors core.sharedRepository' '
409 test_when_finished "rm -rf repo" &&
412 git init --shared=true repo &&
413 test_commit -C repo A &&
414 test_line_count = 3 repo/.git/reftable/tables.list
416 git -C repo pack-refs &&
417 test_expect_perms "-rw-rw-r--" repo/.git/reftable/tables.list &&
418 for table in repo/.git/reftable/*.ref
420 test_expect_perms "-rw-rw-r--" "$table" ||
426 test_expect_success
'packed-refs: writes are synced' '
427 test_when_finished "rm -rf repo" &&
429 test_commit -C repo initial &&
430 test_line_count = 2 table-files &&
433 GIT_TRACE2_EVENT="$(pwd)/trace2.txt" \
434 GIT_TEST_FSYNC=true \
435 git -C repo -c core.fsync=reference \
436 -c core.fsyncMethod=fsync pack-refs &&
437 check_fsync_events trace2.txt <<-EOF
438 "name":"hardware-flush","count":2
442 test_expect_success
'ref iterator: bogus names are flagged' '
443 test_when_finished "rm -rf repo" &&
447 test_commit --no-tag file &&
448 test-tool ref-store main update-ref msg "refs/heads/bogus..name" $(git rev-parse HEAD) $ZERO_OID REF_SKIP_REFNAME_VERIFICATION &&
450 cat >expect <<-EOF &&
451 $ZERO_OID refs/heads/bogus..name 0xc
452 $(git rev-parse HEAD) refs/heads/main 0x0
454 test-tool ref-store main for-each-ref "" >actual &&
455 test_cmp expect actual
459 test_expect_success
'ref iterator: missing object IDs are not flagged' '
460 test_when_finished "rm -rf repo" &&
464 test-tool ref-store main update-ref msg "refs/heads/broken-hash" $INVALID_OID $ZERO_OID REF_SKIP_OID_VERIFICATION &&
466 cat >expect <<-EOF &&
467 $INVALID_OID refs/heads/broken-hash 0x0
469 test-tool ref-store main for-each-ref "" >actual &&
470 test_cmp expect actual
474 test_expect_success
'basic: commit and list refs' '
475 test_when_finished "rm -rf repo" &&
477 test_commit -C repo file &&
478 test_write_lines refs/heads/main refs/tags/file >expect &&
479 git -C repo for-each-ref --format="%(refname)" >actual &&
480 test_cmp actual expect
483 test_expect_success
'basic: can write large commit message' '
484 test_when_finished "rm -rf repo" &&
487 print \"this is a long commit message\" x 50000
489 git -C repo commit --allow-empty --file=../commit-msg
492 test_expect_success
'basic: show-ref fails with empty repository' '
493 test_when_finished "rm -rf repo" &&
495 test_must_fail git -C repo show-ref >actual &&
496 test_must_be_empty actual
499 test_expect_success
'basic: can check out unborn branch' '
500 test_when_finished "rm -rf repo" &&
502 git -C repo checkout -b main
505 test_expect_success
'basic: peeled tags are stored' '
506 test_when_finished "rm -rf repo" &&
508 test_commit -C repo file &&
509 git -C repo tag -m "annotated tag" test_tag HEAD &&
510 for ref in refs/heads/main refs/tags/file refs/tags/test_tag refs/tags/test_tag^{}
512 echo "$(git -C repo rev-parse "$ref") $ref" || return 1
514 git -C repo show-ref -d >actual &&
515 test_cmp expect actual
518 test_expect_success
'basic: for-each-ref can print symrefs' '
519 test_when_finished "rm -rf repo" &&
525 git symbolic-ref refs/heads/sym refs/heads/main &&
526 cat >expected <<-EOF &&
529 git for-each-ref --format="%(symref)" refs/heads/sym >actual &&
530 test_cmp expected actual
534 test_expect_success
'basic: notes' '
535 test_when_finished "rm -rf repo" &&
538 write_script fake_editor <<-\EOF &&
545 GIT_EDITOR=./fake_editor MSG=b4 git notes add &&
546 GIT_EDITOR=./fake_editor MSG=b3 git notes edit &&
548 git notes --ref commits@{1} show >actual &&
549 test_cmp expect actual
553 test_expect_success
'basic: stash' '
554 test_when_finished "rm -rf repo" &&
559 git stash list >expect &&
560 test_line_count = 0 expect &&
563 git stash push -m stashed &&
564 git stash list >expect &&
565 test_line_count = 1 expect &&
568 git stash list >expect &&
569 test_line_count = 0 expect
573 test_expect_success
'basic: cherry-pick' '
574 test_when_finished "rm -rf repo" &&
578 test_commit message1 file1 &&
579 test_commit message2 file2 &&
581 git checkout HEAD^ &&
582 test_commit message3 file3 &&
583 git cherry-pick source &&
584 test_path_is_file file2
588 test_expect_success
'basic: rebase' '
589 test_when_finished "rm -rf repo" &&
593 test_commit message1 file1 &&
594 test_commit message2 file2 &&
596 git checkout HEAD^ &&
597 test_commit message3 file3 &&
599 test_path_is_file file2
603 test_expect_success
'reflog: can delete separate reflog entries' '
604 test_when_finished "rm -rf repo" &&
613 git reflog >actual &&
616 git reflog delete HEAD@{1} &&
617 git reflog >actual &&
622 test_expect_success
'reflog: can switch to previous branch' '
623 test_when_finished "rm -rf repo" &&
628 git checkout -b branch1 &&
630 git checkout -b branch2 &&
632 git rev-parse --symbolic-full-name HEAD >actual &&
633 echo refs/heads/branch1 >expect &&
634 test_cmp actual expect
638 test_expect_success
'reflog: copying branch writes reflog entry' '
639 test_when_finished "rm -rf repo" &&
645 oid=$(git rev-parse --short HEAD) &&
647 cat >expect <<-EOF &&
648 ${oid} dst@{0}: Branch: copied refs/heads/src to refs/heads/dst
649 ${oid} dst@{1}: branch: Created from main
651 git branch -c src dst &&
652 git reflog dst >actual &&
653 test_cmp expect actual
657 test_expect_success
'reflog: renaming branch writes reflog entry' '
658 test_when_finished "rm -rf repo" &&
662 git symbolic-ref HEAD refs/heads/before &&
664 git show-ref >expected.refs &&
665 sed s/before/after/g <expected.refs >expected &&
666 git branch -M after &&
667 git show-ref >actual &&
668 test_cmp expected actual &&
669 echo refs/heads/after >expected &&
670 git symbolic-ref HEAD >actual &&
671 test_cmp expected actual
675 test_expect_success
'reflog: can store empty logs' '
676 test_when_finished "rm -rf repo" &&
681 test_must_fail test-tool ref-store main reflog-exists refs/heads/branch &&
682 test-tool ref-store main create-reflog refs/heads/branch &&
683 test-tool ref-store main reflog-exists refs/heads/branch &&
684 test-tool ref-store main for-each-reflog-ent-reverse refs/heads/branch >actual &&
685 test_must_be_empty actual
689 test_expect_success
'reflog: expiry empties reflog' '
690 test_when_finished "rm -rf repo" &&
695 test_commit initial &&
696 git checkout -b branch &&
700 cat >expect <<-EOF &&
703 branch: Created from HEAD
705 git reflog show --format="%gs" refs/heads/branch >actual &&
706 test_cmp expect actual &&
708 git reflog expire branch --expire=all &&
709 git reflog show --format="%gs" refs/heads/branch >actual &&
710 test_must_be_empty actual &&
711 test-tool ref-store main reflog-exists refs/heads/branch
715 test_expect_success
'reflog: can be deleted' '
716 test_when_finished "rm -rf repo" &&
720 test_commit initial &&
721 test-tool ref-store main reflog-exists refs/heads/main &&
722 test-tool ref-store main delete-reflog refs/heads/main &&
723 test_must_fail test-tool ref-store main reflog-exists refs/heads/main
727 test_expect_success
'reflog: garbage collection deletes reflog entries' '
728 test_when_finished "rm -rf repo" &&
733 for count in $(test_seq 1 10)
735 test_commit "number $count" file.t $count number-$count ||
738 git reflog refs/heads/main >actual &&
739 test_line_count = 10 actual &&
740 grep "commit (initial): number 1" actual &&
741 grep "commit: number 10" actual &&
744 git reflog refs/heads/main >actual &&
745 test_line_count = 0 actual
749 test_expect_success
'reflog: updates via HEAD update HEAD reflog' '
750 test_when_finished "rm -rf repo" &&
754 test_commit main-one &&
755 git checkout -b new-branch &&
756 test_commit new-one &&
757 test_commit new-two &&
759 echo new-one >expect &&
760 git log -1 --format=%s HEAD@{1} >actual &&
761 test_cmp expect actual
765 test_expect_success
'worktree: adding worktree creates separate stack' '
766 test_when_finished "rm -rf repo worktree" &&
768 test_commit -C repo A &&
770 git -C repo worktree add ../worktree &&
771 test_path_is_file repo/.git/worktrees/worktree/refs/heads &&
772 echo "ref: refs/heads/.invalid" >expect &&
773 test_cmp expect repo/.git/worktrees/worktree/HEAD &&
774 test_path_is_dir repo/.git/worktrees/worktree/reftable &&
775 test_path_is_file repo/.git/worktrees/worktree/reftable/tables.list
778 test_expect_success
'worktree: pack-refs in main repo packs main refs' '
779 test_when_finished "rm -rf repo worktree" &&
781 test_commit -C repo A &&
782 git -C repo worktree add ../worktree &&
784 test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
785 test_line_count = 4 repo/.git/reftable/tables.list &&
786 git -C repo pack-refs &&
787 test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
788 test_line_count = 1 repo/.git/reftable/tables.list
791 test_expect_success
'worktree: pack-refs in worktree packs worktree refs' '
792 test_when_finished "rm -rf repo worktree" &&
794 test_commit -C repo A &&
795 git -C repo worktree add ../worktree &&
797 test_line_count = 3 repo/.git/worktrees/worktree/reftable/tables.list &&
798 test_line_count = 4 repo/.git/reftable/tables.list &&
799 git -C worktree pack-refs &&
800 test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
801 test_line_count = 4 repo/.git/reftable/tables.list
804 test_expect_success
'worktree: creating shared ref updates main stack' '
805 test_when_finished "rm -rf repo worktree" &&
807 test_commit -C repo A &&
809 git -C repo worktree add ../worktree &&
810 git -C repo pack-refs &&
811 git -C worktree pack-refs &&
812 test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
813 test_line_count = 1 repo/.git/reftable/tables.list &&
815 git -C worktree update-ref refs/heads/shared HEAD &&
816 test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
817 test_line_count = 2 repo/.git/reftable/tables.list
820 test_expect_success
'worktree: creating per-worktree ref updates worktree stack' '
821 test_when_finished "rm -rf repo worktree" &&
823 test_commit -C repo A &&
825 git -C repo worktree add ../worktree &&
826 git -C repo pack-refs &&
827 git -C worktree pack-refs &&
828 test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
829 test_line_count = 1 repo/.git/reftable/tables.list &&
831 git -C worktree update-ref refs/bisect/per-worktree HEAD &&
832 test_line_count = 2 repo/.git/worktrees/worktree/reftable/tables.list &&
833 test_line_count = 1 repo/.git/reftable/tables.list
836 test_expect_success
'worktree: creating per-worktree ref from main repo' '
837 test_when_finished "rm -rf repo worktree" &&
839 test_commit -C repo A &&
841 git -C repo worktree add ../worktree &&
842 git -C repo pack-refs &&
843 git -C worktree pack-refs &&
844 test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
845 test_line_count = 1 repo/.git/reftable/tables.list &&
847 git -C repo update-ref worktrees/worktree/refs/bisect/per-worktree HEAD &&
848 test_line_count = 2 repo/.git/worktrees/worktree/reftable/tables.list &&
849 test_line_count = 1 repo/.git/reftable/tables.list
852 test_expect_success
'worktree: creating per-worktree ref from second worktree' '
853 test_when_finished "rm -rf repo wt1 wt2" &&
855 test_commit -C repo A &&
857 git -C repo worktree add ../wt1 &&
858 git -C repo worktree add ../wt2 &&
859 git -C repo pack-refs &&
860 git -C wt1 pack-refs &&
861 git -C wt2 pack-refs &&
862 test_line_count = 1 repo/.git/worktrees/wt1/reftable/tables.list &&
863 test_line_count = 1 repo/.git/worktrees/wt2/reftable/tables.list &&
864 test_line_count = 1 repo/.git/reftable/tables.list &&
866 git -C wt1 update-ref worktrees/wt2/refs/bisect/per-worktree HEAD &&
867 test_line_count = 1 repo/.git/worktrees/wt1/reftable/tables.list &&
868 test_line_count = 2 repo/.git/worktrees/wt2/reftable/tables.list &&
869 test_line_count = 1 repo/.git/reftable/tables.list
872 test_expect_success
'worktree: can create shared and per-worktree ref in one transaction' '
873 test_when_finished "rm -rf repo worktree" &&
875 test_commit -C repo A &&
877 git -C repo worktree add ../worktree &&
878 git -C repo pack-refs &&
879 git -C worktree pack-refs &&
880 test_line_count = 1 repo/.git/worktrees/worktree/reftable/tables.list &&
881 test_line_count = 1 repo/.git/reftable/tables.list &&
884 create worktrees/worktree/refs/bisect/per-worktree HEAD
885 create refs/branches/shared HEAD
887 git -C repo update-ref --stdin <stdin &&
888 test_line_count = 2 repo/.git/worktrees/worktree/reftable/tables.list &&
889 test_line_count = 2 repo/.git/reftable/tables.list
892 test_expect_success
'worktree: can access common refs' '
893 test_when_finished "rm -rf repo worktree" &&
895 test_commit -C repo file1 &&
896 git -C repo branch branch1 &&
897 git -C repo worktree add ../worktree &&
899 echo refs/heads/worktree >expect &&
900 git -C worktree symbolic-ref HEAD >actual &&
901 test_cmp expect actual &&
902 git -C worktree checkout branch1
905 test_expect_success
'worktree: adds worktree with detached HEAD' '
906 test_when_finished "rm -rf repo worktree" &&
909 test_commit -C repo A &&
910 git -C repo rev-parse main >expect &&
912 git -C repo worktree add --detach ../worktree main &&
913 git -C worktree rev-parse HEAD >actual &&
914 test_cmp expect actual
917 test_expect_success
'fetch: accessing FETCH_HEAD special ref works' '
918 test_when_finished "rm -rf repo sub" &&
921 test_commit -C sub two &&
922 git -C sub rev-parse HEAD >expect &&
925 test_commit -C repo one &&
926 git -C repo fetch ../sub &&
927 git -C repo rev-parse FETCH_HEAD >actual &&
928 test_cmp expect actual