| 334 | } |
| 335 | |
| 336 | int cmd_reset(int argc, |
| 337 | const char **argv, |
| 338 | const char *prefix, |
| 339 | struct repository *repo UNUSED) |
| 340 | { |
| 341 | int reset_type = NONE, update_ref_status = 0, quiet = 0; |
| 342 | int no_refresh = 0; |
| 343 | int patch_mode = 0, pathspec_file_nul = 0, unborn; |
| 344 | const char *rev; |
| 345 | char *pathspec_from_file = NULL; |
| 346 | struct object_id oid; |
| 347 | struct pathspec pathspec; |
| 348 | int intent_to_add = 0; |
| 349 | struct interactive_options interactive_opts = INTERACTIVE_OPTIONS_INIT; |
| 350 | const struct option options[] = { |
| 351 | OPT__QUIET(&quiet, N_("be quiet, only report errors")), |
| 352 | OPT_BOOL(0, "no-refresh", &no_refresh, |
| 353 | N_("skip refreshing the index after reset")), |
| 354 | OPT_SET_INT_F(0, "mixed", &reset_type, |
| 355 | N_("reset HEAD and index"), |
| 356 | MIXED, PARSE_OPT_NONEG), |
| 357 | OPT_SET_INT_F(0, "soft", &reset_type, |
| 358 | N_("reset only HEAD"), |
| 359 | SOFT, PARSE_OPT_NONEG), |
| 360 | OPT_SET_INT_F(0, "hard", &reset_type, |
| 361 | N_("reset HEAD, index and working tree"), |
| 362 | HARD, PARSE_OPT_NONEG), |
| 363 | OPT_SET_INT_F(0, "merge", &reset_type, |
| 364 | N_("reset HEAD, index and working tree"), |
| 365 | MERGE, PARSE_OPT_NONEG), |
| 366 | OPT_SET_INT_F(0, "keep", &reset_type, |
| 367 | N_("reset HEAD but keep local changes"), |
| 368 | KEEP, PARSE_OPT_NONEG), |
| 369 | OPT_CALLBACK_F(0, "recurse-submodules", NULL, |
| 370 | "reset", "control recursive updating of submodules", |
| 371 | PARSE_OPT_OPTARG, |
| 372 | option_parse_recurse_submodules_worktree_updater), |
| 373 | OPT_BOOL('p', "patch", &patch_mode, N_("select hunks interactively")), |
| 374 | OPT_BOOL(0, "auto-advance", &interactive_opts.auto_advance, |
| 375 | N_("auto advance to the next file when selecting hunks interactively")), |
| 376 | OPT_DIFF_UNIFIED(&interactive_opts.context), |
| 377 | OPT_DIFF_INTERHUNK_CONTEXT(&interactive_opts.interhunkcontext), |
| 378 | OPT_BOOL('N', "intent-to-add", &intent_to_add, |
| 379 | N_("record only the fact that removed paths will be added later")), |
| 380 | OPT_PATHSPEC_FROM_FILE(&pathspec_from_file), |
| 381 | OPT_PATHSPEC_FILE_NUL(&pathspec_file_nul), |
| 382 | OPT_END() |
| 383 | }; |
| 384 | |
| 385 | repo_config(the_repository, git_reset_config, NULL); |
| 386 | |
| 387 | argc = parse_options(argc, argv, prefix, options, git_reset_usage, |
| 388 | PARSE_OPT_KEEP_DASHDASH); |
| 389 | parse_args(&pathspec, argv, prefix, patch_mode, &rev); |
| 390 | |
| 391 | if (pathspec_from_file) { |
| 392 | if (patch_mode) |
| 393 | die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--patch"); |
no test coverage detected