int no_dwim_new_local_branch;
        int discard_changes;
        int accept_pathspec;
+       int switch_branch_doing_nothing_is_ok;
 
        /*
         * If new checkout options are added, skip_merge_working_tree
                die(_("Cannot switch branch to a non-commit '%s'"),
                    new_branch_info->name);
 
+       if (!opts->switch_branch_doing_nothing_is_ok &&
+           !new_branch_info->name &&
+           !opts->new_branch &&
+           !opts->force_detach)
+               die(_("missing branch or commit argument"));
+
        if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
            !opts->ignore_other_worktrees) {
                int flag;
 
        memset(&opts, 0, sizeof(opts));
        opts.no_dwim_new_local_branch = 0;
+       opts.switch_branch_doing_nothing_is_ok = 1;
        opts.accept_pathspec = 1;
 
        options = parse_options_dup(checkout_options);
        memset(&opts, 0, sizeof(opts));
        opts.no_dwim_new_local_branch = 0;
        opts.accept_pathspec = 0;
+       opts.switch_branch_doing_nothing_is_ok = 0;
 
        options = parse_options_dup(switch_options);
        options = add_common_options(&opts, options);