| 788 | } |
| 789 | |
| 790 | static int add(int ac, const char **av, const char *prefix, |
| 791 | struct repository *repo UNUSED) |
| 792 | { |
| 793 | struct add_opts opts; |
| 794 | const char *new_branch_force = NULL; |
| 795 | char *path; |
| 796 | const char *branch; |
| 797 | char *branch_to_free = NULL; |
| 798 | char *new_branch_to_free = NULL; |
| 799 | const char *new_branch = NULL; |
| 800 | char *opt_track = NULL; |
| 801 | const char *lock_reason = NULL; |
| 802 | int keep_locked = 0; |
| 803 | int used_new_branch_options; |
| 804 | struct option options[] = { |
| 805 | OPT__FORCE(&opts.force, |
| 806 | N_("checkout <branch> even if already checked out in other worktree"), |
| 807 | PARSE_OPT_NOCOMPLETE), |
| 808 | OPT_STRING('b', NULL, &new_branch, N_("branch"), |
| 809 | N_("create a new branch")), |
| 810 | OPT_STRING('B', NULL, &new_branch_force, N_("branch"), |
| 811 | N_("create or reset a branch")), |
| 812 | OPT_BOOL(0, "orphan", &opts.orphan, N_("create unborn branch")), |
| 813 | OPT_BOOL('d', "detach", &opts.detach, N_("detach HEAD at named commit")), |
| 814 | OPT_BOOL(0, "checkout", &opts.checkout, N_("populate the new working tree")), |
| 815 | OPT_BOOL(0, "lock", &keep_locked, N_("keep the new working tree locked")), |
| 816 | OPT_STRING(0, "reason", &lock_reason, N_("string"), |
| 817 | N_("reason for locking")), |
| 818 | OPT__QUIET(&opts.quiet, N_("suppress progress reporting")), |
| 819 | OPT_PASSTHRU(0, "track", &opt_track, NULL, |
| 820 | N_("set up tracking mode (see git-branch(1))"), |
| 821 | PARSE_OPT_NOARG | PARSE_OPT_OPTARG), |
| 822 | OPT_BOOL(0, "guess-remote", &guess_remote, |
| 823 | N_("try to match the new branch name with a remote-tracking branch")), |
| 824 | OPT_BOOL(0, "relative-paths", &opts.relative_paths, |
| 825 | N_("use relative paths for worktrees")), |
| 826 | OPT_END() |
| 827 | }; |
| 828 | int ret; |
| 829 | |
| 830 | memset(&opts, 0, sizeof(opts)); |
| 831 | opts.checkout = 1; |
| 832 | opts.relative_paths = use_relative_paths; |
| 833 | ac = parse_options(ac, av, prefix, options, git_worktree_add_usage, 0); |
| 834 | if (!!opts.detach + !!new_branch + !!new_branch_force > 1) |
| 835 | die(_("options '%s', '%s', and '%s' cannot be used together"), "-b", "-B", "--detach"); |
| 836 | if (opts.detach && opts.orphan) |
| 837 | die(_("options '%s' and '%s' cannot be used together"), |
| 838 | "--orphan", "--detach"); |
| 839 | if (opts.orphan && opt_track) |
| 840 | die(_("options '%s' and '%s' cannot be used together"), |
| 841 | "--orphan", "--track"); |
| 842 | if (opts.orphan && !opts.checkout) |
| 843 | die(_("options '%s' and '%s' cannot be used together"), |
| 844 | "--orphan", "--no-checkout"); |
| 845 | if (opts.orphan && ac == 2) |
| 846 | die(_("option '%s' and commit-ish cannot be used together"), |
| 847 | "--orphan"); |
nothing calls this directly
no test coverage detected