Re: [PATCH] worktree: repair copied repository and linked worktrees
On Tuesday, October 8th, 2024 at 10:30, Caleb White <cdwhite3@pm.me> wrote:
Show 25 quoted lines
> test_expect_success 'does not repair worktrees from another repo' '
> test_when_finished "rm -rf repo1 repo2" &&
> mkdir -p repo1 &&
> git -C repo1 init main &&
> test_commit -C repo1/main nothing &&
> git -C repo1/main worktree add ../linked &&
> cp repo1/main/.git/worktrees/linked/gitdir repo1/main.expect &&
> cp repo1/linked/.git repo1/linked.expect &&
> mkdir -p repo2 &&
> git -C repo2 init main &&
> test_commit -C repo2/main nothing &&
> git -C repo2/main worktree add ../linked &&
> cp repo2/main/.git/worktrees/linked/gitdir repo2/main.expect &&
> cp repo2/linked/.git repo2/linked.expect &&
> git -C repo1/main worktree repair ../.. &&
> test_cmp repo1/main.expect repo1/main/.git/worktrees/linked/gitdir &&
> test_cmp repo1/linked.expect repo1/linked/.git &&
> test_cmp repo2/main.expect repo2/main/.git/worktrees/linked/gitdir &&
> test_cmp repo2/linked.expect repo2/linked/.git &&
> git -C repo2/main worktree repair ../../repo1/linked &&
> test_cmp repo1/main.expect repo1/main/.git/worktrees/linked/gitdir &&
> test_cmp repo1/linked.expect repo1/linked/.git &&
> test_cmp repo2/main.expect repo2/main/.git/worktrees/linked/gitdir &&
> test_cmp repo2/linked.expect repo2/linked/.git
> '
Apologies on this test case, it should be:
test_expect_success 'does not repair worktrees from another repo' '
test_when_finished "rm -rf repo1 repo2" &&
mkdir -p repo1 &&
git -C repo1 init main &&
test_commit -C repo1/main nothing &&
git -C repo1/main worktree add ../linked &&
cp repo1/main/.git/worktrees/linked/gitdir repo1/main.expect &&
cp repo1/linked/.git repo1/linked.expect &&
mkdir -p repo2 &&
git -C repo2 init main &&
test_commit -C repo2/main nothing &&
git -C repo2/main worktree add ../linked &&
cp repo2/main/.git/worktrees/linked/gitdir repo2/main.expect &&
cp repo2/linked/.git repo2/linked.expect &&
git -C repo1/main worktree repair ../../repo2/linked &&
test_cmp repo1/main.expect repo1/main/.git/worktrees/linked/gitdir &&
test_cmp repo1/linked.expect repo1/linked/.git &&
test_cmp repo2/main.expect repo2/main/.git/worktrees/linked/gitdir &&
test_cmp repo2/linked.expect repo2/linked/.git &&
git -C repo2/main worktree repair ../../repo1/linked &&
test_cmp repo1/main.expect repo1/main/.git/worktrees/linked/gitdir &&
test_cmp repo1/linked.expect repo1/linked/.git &&
test_cmp repo2/main.expect repo2/main/.git/worktrees/linked/gitdir &&
test_cmp repo2/linked.expect repo2/linked/.git
'- Caleb