checkout: Don't crash when switching away from an invalid branch.