Fix infinite loop when worktree is deleted (#39637)

Closes #39442

Release Notes:

- Fixed infinite loop when worktree is deleted

Co-authored-by: Conrad Irwin <conrad.irwin@gmail.com>
c80d213227Andrew Farkas committed on 10/6/2025, 7:20:01 PM· committed by GitHubparentfe9895d
2 files changedLine totals unavailable