return newopts;
}
-static struct option *add_switch_branch_options(struct checkout_opts *opts,
- struct option *prevopts)
+static struct option *add_common_switch_branch_options(
+ struct checkout_opts *opts, struct option *prevopts)
{
struct option options[] = {
- OPT_STRING('b', NULL, &opts->new_branch, N_("branch"),
- N_("create and checkout a new branch")),
- OPT_STRING('B', NULL, &opts->new_branch_force, N_("branch"),
- N_("create/reset and checkout a branch")),
OPT_BOOL('l', NULL, &opts->new_branch_log, N_("create reflog for new branch")),
OPT_BOOL(0, "detach", &opts->force_detach, N_("detach HEAD at named commit")),
OPT_SET_INT('t', "track", &opts->track, N_("set upstream info for new branch"),
int cmd_checkout(int argc, const char **argv, const char *prefix)
{
struct checkout_opts opts;
- struct option *options = NULL;
+ struct option *options;
+ struct option checkout_options[] = {
+ OPT_STRING('b', NULL, &opts.new_branch, N_("branch"),
+ N_("create and checkout a new branch")),
+ OPT_STRING('B', NULL, &opts.new_branch_force, N_("branch"),
+ N_("create/reset and checkout a branch")),
+ OPT_END()
+ };
int ret;
memset(&opts, 0, sizeof(opts));
opts.no_dwim_new_local_branch = 0;
- options = parse_options_dup(options);
+ options = parse_options_dup(checkout_options);
options = add_common_options(&opts, options);
- options = add_switch_branch_options(&opts, options);
+ options = add_common_switch_branch_options(&opts, options);
options = add_checkout_path_options(&opts, options);
ret = checkout_main(argc, argv, prefix, &opts,
{
struct checkout_opts opts;
struct option *options = NULL;
+ struct option switch_options[] = {
+ OPT_STRING('c', "create", &opts.new_branch, N_("branch"),
+ N_("create and switch to a new branch")),
+ OPT_STRING('C', "force-create", &opts.new_branch_force, N_("branch"),
+ N_("create/reset and switch to a branch")),
+ OPT_END()
+ };
int ret;
memset(&opts, 0, sizeof(opts));
opts.no_dwim_new_local_branch = 0;
- options = parse_options_dup(options);
+ options = parse_options_dup(switch_options);
options = add_common_options(&opts, options);
- options = add_switch_branch_options(&opts, options);
+ options = add_common_switch_branch_options(&opts, options);
ret = checkout_main(argc, argv, prefix, &opts,
options, switch_branch_usage);