The logic is stolen from the similar action implemented in the RepoView. You may be deleting a branch which is ahead of the currently checked out one or you may be headless. In both cases, when the branch is deleted, there is nothing left after deletion that would keep the garbage collector from gobbling up the commit.