| 515 | } |
| 516 | |
| 517 | static int checkout_paths(const struct checkout_opts *opts, |
| 518 | const struct branch_info *new_branch_info) |
| 519 | { |
| 520 | int pos; |
| 521 | static char *ps_matched; |
| 522 | struct object_id rev; |
| 523 | struct commit *head; |
| 524 | int errs = 0; |
| 525 | struct lock_file lock_file = LOCK_INIT; |
| 526 | int checkout_index; |
| 527 | |
| 528 | trace2_cmd_mode(opts->patch_mode ? "patch" : "path"); |
| 529 | |
| 530 | if (opts->track != BRANCH_TRACK_UNSPECIFIED) |
| 531 | die(_("'%s' cannot be used with updating paths"), "--track"); |
| 532 | |
| 533 | if (opts->new_branch_log) |
| 534 | die(_("'%s' cannot be used with updating paths"), "-l"); |
| 535 | |
| 536 | if (opts->ignore_unmerged && opts->patch_mode) |
| 537 | die(_("'%s' cannot be used with updating paths"), |
| 538 | opts->ignore_unmerged_opt); |
| 539 | |
| 540 | if (opts->force_detach) |
| 541 | die(_("'%s' cannot be used with updating paths"), "--detach"); |
| 542 | |
| 543 | if (opts->merge && opts->patch_mode) |
| 544 | die(_("options '%s' and '%s' cannot be used together"), "--merge", "--patch"); |
| 545 | |
| 546 | if (opts->ignore_unmerged && opts->merge) |
| 547 | die(_("options '%s' and '%s' cannot be used together"), |
| 548 | opts->ignore_unmerged_opt, "-m"); |
| 549 | |
| 550 | if (opts->new_branch) |
| 551 | die(_("Cannot update paths and switch to branch '%s' at the same time."), |
| 552 | opts->new_branch); |
| 553 | |
| 554 | if (!opts->checkout_worktree && !opts->checkout_index) |
| 555 | die(_("neither '%s' or '%s' is specified"), |
| 556 | "--staged", "--worktree"); |
| 557 | |
| 558 | if (!opts->checkout_worktree && !opts->from_treeish) |
| 559 | die(_("'%s' must be used when '%s' is not specified"), |
| 560 | "--worktree", "--source"); |
| 561 | |
| 562 | /* |
| 563 | * Reject --staged option to the restore command when combined with |
| 564 | * merge-related options. Use the accept_ref flag to distinguish it |
| 565 | * from the checkout command, which does not accept --staged anyway. |
| 566 | * |
| 567 | * `restore --ours|--theirs --worktree --staged` could mean resolving |
| 568 | * conflicted paths to one side in both the worktree and the index, |
| 569 | * but does not currently. |
| 570 | * |
| 571 | * `restore --merge|--conflict=<style>` already recreates conflicts |
| 572 | * in both the worktree and the index, so adding --staged would be |
| 573 | * meaningless. |
| 574 | */ |
no test coverage detected