# git: Fix create worktree hook tasks running when switching worktrees \(\#54612\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/b830524713a0f41a83f8bdb2809e640f150d71dd)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: b830524713a0f41a83f8bdb2809e640f150d71dd

Requested commit: b830524713a0f41a83f8bdb2809e640f150d71dd

Commit: b830524713a0f41a83f8bdb2809e640f150d71dd

Tree: 6f3b87b68f43e2d1a915389f2af620d003bacfe5

Author: Anthony Eid

Committer: GitHub

## Message

```
git: Fix create worktree hook tasks running when switching worktrees (#54612)

This PR fixes a regression that was likely caused by:
https://github.com/zed-industries/zed/pull/54183 and wasn't caught
because I didn't add a regression test when I originally created the
feature.

The fix was only running the hooks when the worktree was just created,
and I added an integration test to prevent regressions from occurring
again in the future.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Closes #54598

Release Notes:

- git: Fix create worktree hook tasks running when switching worktrees
```

## Parents

- [61b25b6119711f3ae713946474054e36690700d4](https://git.cafe/gitcafe/zed/commit/61b25b6119711f3ae713946474054e36690700d4?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/b830524713a0f41a83f8bdb2809e640f150d71dd?format=markdown)
