builtin/checkout: handle -B from detached HEAD correctly