MCPcopy Create free account
hub / github.com/git/git / cmd_switch

Function cmd_switch

builtin/checkout.c:2141–2178  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2139}
2140
2141int cmd_switch(int argc,
2142 const char **argv,
2143 const char *prefix,
2144 struct repository *repo UNUSED)
2145{
2146 struct checkout_opts opts = CHECKOUT_OPTS_INIT;
2147 struct option *options = NULL;
2148 struct option switch_options[] = {
2149 OPT_STRING('c', "create", &opts.new_branch, N_("branch"),
2150 N_("create and switch to a new branch")),
2151 OPT_STRING('C', "force-create", &opts.new_branch_force, N_("branch"),
2152 N_("create/reset and switch to a branch")),
2153 OPT_BOOL(0, "guess", &opts.dwim_new_local_branch,
2154 N_("second guess 'git switch <no-such-branch>'")),
2155 OPT_BOOL(0, "discard-changes", &opts.discard_changes,
2156 N_("throw away local modifications")),
2157 OPT_END()
2158 };
2159
2160 opts.dwim_new_local_branch = 1;
2161 opts.accept_ref = 1;
2162 opts.accept_pathspec = 0;
2163 opts.switch_branch_doing_nothing_is_ok = 0;
2164 opts.only_merge_on_switching_branches = 1;
2165 opts.implicit_detach = 0;
2166 opts.can_switch_when_in_progress = 0;
2167 opts.orphan_from_empty_tree = 1;
2168 opts.overlay_mode = -1;
2169
2170 options = parse_options_dup(switch_options);
2171 options = add_common_options(&opts, options);
2172 options = add_common_switch_branch_options(&opts, options);
2173
2174 cb_option = 'c';
2175
2176 return checkout_main(argc, argv, prefix, &opts, options,
2177 CHECKOUT_SWITCH);
2178}
2179
2180int cmd_restore(int argc,
2181 const char **argv,

Callers

nothing calls this directly

Calls 4

parse_options_dupFunction · 0.85
checkout_mainFunction · 0.85
add_common_optionsFunction · 0.70

Tested by

no test coverage detected