From 4c076bbaea77dd1b5bc7cf43bd99006bff9b756e Mon Sep 17 00:00:00 2001 From: Matthias Koeppe Date: Sun, 12 May 2024 23:47:47 -0700 Subject: [PATCH] .ci/retrofit-worktree.sh: Prune old worktree if needed --- .ci/retrofit-worktree.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.ci/retrofit-worktree.sh b/.ci/retrofit-worktree.sh index b399c4b4043..5dcb6e2b88f 100755 --- a/.ci/retrofit-worktree.sh +++ b/.ci/retrofit-worktree.sh @@ -38,6 +38,10 @@ git tag -f new # The changed files now show up as uncommitted changes. # The final "git add -N" makes sure that files that were added in "new" do not show # as untracked files, which would be removed by "git clean -fx". +if [ -L $WORKTREE_NAME ]; then + rm -f $WORKTREE_NAME + git worktree prune --verbose +fi git worktree add --detach $WORKTREE_NAME rm -rf $WORKTREE_DIRECTORY/.git && mv $WORKTREE_NAME/.git $WORKTREE_DIRECTORY/ rm -rf $WORKTREE_NAME && ln -s $WORKTREE_DIRECTORY $WORKTREE_NAME