I think this is not quite the correct check. It should be something like

if (ObjectId.isId(repository.getFullBranch()) && bop.getResult().....)

instead. This will also make the change in CheckoutCommand obsolete. The point is, we shouldn't rely on the refName parameter to decide whether the head is detached after the operation or not.

For example, right now, with this code, you would get a wrong detached head warning pop-up when trying to checkout a remote branch pointing to the same commit as the currently checked out branch as a consequence of bug 315166.