Make sure refs/rewritten/ is per-worktree
a9be29c981
(sequencer: make refs generated by the `label` command
worktree-local, 2018-04-25) adds refs/rewritten/ as per-worktree
reference space. Unfortunately (my bad) there are a couple places that
need update to make sure it's really per-worktree.
- add_per_worktree_entries_to_dir() is updated to make sure ref listing
look at per-worktree refs/rewritten/ instead of per-repo one [1]
- common_list[] is updated so that git_path() returns the correct
location. This includes "rev-parse --git-path".
This mess is created by me. I started trying to fix it with the
introduction of refs/worktree, where all refs will be per-worktree
without special treatments. Unfortunate refs/rewritten came before
refs/worktree so this is all we can do.
This also fixes logs/refs/worktree not being per-worktree.
[1] note that ref listing still works sometimes. For example, if you
have .git/worktrees/foo/refs/rewritten/bar AND the directory
.git/worktrees/refs/rewritten, refs/rewritten/bar will show up.
add_per_worktree_entries_to_dir() is only needed when the directory
.git/worktrees/refs/rewritten is missing.
Reported-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
90d31ff5d4
commit
b9317d55a3
@ -76,4 +76,39 @@ test_expect_success 'reflog of worktrees/xx/HEAD' '
|
||||
test_cmp expected actual.wt2
|
||||
'
|
||||
|
||||
test_expect_success 'for-each-ref from main repo' '
|
||||
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 &&
|
||||
cat >expected <<-\EOF &&
|
||||
refs/bisect/main
|
||||
refs/rewritten/main
|
||||
refs/worktree/main
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'for-each-ref from linked repo' '
|
||||
mkdir fer2 &&
|
||||
git -C fer2 init repo &&
|
||||
test_commit -C fer2/repo initial &&
|
||||
git -C fer2/repo worktree add ../second &&
|
||||
git -C fer2/second update-ref refs/bisect/second HEAD &&
|
||||
git -C fer2/second update-ref refs/rewritten/second HEAD &&
|
||||
git -C fer2/second update-ref refs/worktree/second HEAD &&
|
||||
git -C fer2/second for-each-ref --format="%(refname)" | grep second >actual &&
|
||||
cat >expected <<-\EOF &&
|
||||
refs/bisect/second
|
||||
refs/heads/second
|
||||
refs/rewritten/second
|
||||
refs/worktree/second
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Reference in New Issue
Block a user