diff options
Diffstat (limited to 't/t1415-worktree-refs.sh')
-rwxr-xr-x | t/t1415-worktree-refs.sh | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/t/t1415-worktree-refs.sh b/t/t1415-worktree-refs.sh index bb2c7572a3..a3e6ea0808 100755 --- a/t/t1415-worktree-refs.sh +++ b/t/t1415-worktree-refs.sh @@ -16,7 +16,10 @@ test_expect_success 'setup' ' git -C wt2 update-ref refs/worktree/foo HEAD ' -test_expect_success 'refs/worktree must not be packed' ' +# The 'packed-refs' file is stored directly in .git/. This means it is global +# to the repository, and can only contain refs that are shared across all +# worktrees. +test_expect_success REFFILES 'refs/worktree must not be packed' ' git pack-refs --all && test_path_is_missing .git/refs/tags/wt1 && test_path_is_file .git/refs/worktree/foo && @@ -37,9 +40,8 @@ test_expect_success 'resolve main-worktree/HEAD' ' ' test_expect_success 'ambiguous main-worktree/HEAD' ' - mkdir -p .git/refs/heads/main-worktree && - test_when_finished rm -f .git/refs/heads/main-worktree/HEAD && - cp .git/HEAD .git/refs/heads/main-worktree/HEAD && + test_when_finished git update-ref -d refs/heads/main-worktree/HEAD && + git update-ref refs/heads/main-worktree/HEAD $(git rev-parse HEAD) && git rev-parse main-worktree/HEAD 2>warn && grep "main-worktree/HEAD.*ambiguous" warn ' @@ -51,9 +53,8 @@ test_expect_success 'resolve worktrees/xx/HEAD' ' ' test_expect_success 'ambiguous worktrees/xx/HEAD' ' - mkdir -p .git/refs/heads/worktrees/wt1 && - test_when_finished rm -f .git/refs/heads/worktrees/wt1/HEAD && - cp .git/HEAD .git/refs/heads/worktrees/wt1/HEAD && + git update-ref refs/heads/worktrees/wt1/HEAD $(git rev-parse HEAD) && + test_when_finished git update-ref -d refs/heads/worktrees/wt1/HEAD && git rev-parse worktrees/wt1/HEAD 2>warn && grep "worktrees/wt1/HEAD.*ambiguous" warn ' @@ -76,24 +77,24 @@ test_expect_success 'reflog of worktrees/xx/HEAD' ' test_cmp expected actual.wt2 ' -test_expect_success 'for-each-ref from main repo' ' +test_expect_success 'for-each-ref from main worktree' ' mkdir fer1 && git -C fer1 init repo && test_commit -C fer1/repo initial && git -C fer1/repo worktree add ../second && - git -C fer1/repo update-ref refs/bisect/main HEAD && - git -C fer1/repo update-ref refs/rewritten/main HEAD && - git -C fer1/repo update-ref refs/worktree/main HEAD && - git -C fer1/repo for-each-ref --format="%(refname)" | grep main >actual && + git -C fer1/repo update-ref refs/bisect/first HEAD && + git -C fer1/repo update-ref refs/rewritten/first HEAD && + git -C fer1/repo update-ref refs/worktree/first HEAD && + git -C fer1/repo for-each-ref --format="%(refname)" | grep first >actual && cat >expected <<-\EOF && - refs/bisect/main - refs/rewritten/main - refs/worktree/main + refs/bisect/first + refs/rewritten/first + refs/worktree/first EOF test_cmp expected actual ' -test_expect_success 'for-each-ref from linked repo' ' +test_expect_success 'for-each-ref from linked worktree' ' mkdir fer2 && git -C fer2 init repo && test_commit -C fer2/repo initial && |