# git: Fix deletion icon button in branch list deleting the wrong branch \(\#45087\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 93246163c677d226e184606f3782f54edccc7fc2

Requested commit: 93246163c677d226e184606f3782f54edccc7fc2

Commit: 93246163c677d226e184606f3782f54edccc7fc2

Tree: 84ed982f902ce8e0c53e77791a71e70a498cca54

Author: Anthony Eid

Committer: GitHub

## Message

```
git: Fix deletion icon button in branch list deleting the wrong branch (#45087)

Closes #45033 

This bug happened because the deletion icon would use the selected entry
index to choose what branch to delete. This works for all cases except
when hovering on an entry, so the fix was passing in the entry index to
the deletion button on_click handler.

I also disabled the deletion button from working if a branch is HEAD,
because it's an illegal operation to delete a branch a user is currently
on.

Finally, I made WeakEntity<Workspace> a non-optional field on
`BranchList` because a workspace should always be present, and it's used
to show toast notifications when a git operation fails. The popover view
wouldn't have a workspace before, so users wouldn't get error messages
when a git operation failed in that view.

Release Notes:

- git: Fix bug where branch list deletion button would delete the wrong
branch
```

## Parents

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

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