]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/checkout.c
Merge branch 'ab/config-based-hooks-2'
[thirdparty/git.git] / builtin / checkout.c
index e2e95445407cd3952e497b2a1afc8edc224f8589..8f010412a9cdc957ff8ceac841c7cb14b6d55b5a 100644 (file)
@@ -465,10 +465,10 @@ static int checkout_paths(const struct checkout_opts *opts,
                die(_("'%s' cannot be used with updating paths"), "--detach");
 
        if (opts->merge && opts->patch_mode)
-               die(_("'%s' cannot be used with %s"), "--merge", "--patch");
+               die(_("options '%s' and '%s' cannot be used together"), "--merge", "--patch");
 
        if (opts->ignore_unmerged && opts->merge)
-               die(_("'%s' cannot be used with %s"),
+               die(_("options '%s' and '%s' cannot be used together"),
                    opts->ignore_unmerged_opt, "-m");
 
        if (opts->new_branch)
@@ -1095,9 +1095,6 @@ static int switch_branches(const struct checkout_opts *opts,
                const char *p;
                if (skip_prefix(old_branch_info.path, prefix, &p))
                        old_branch_info.name = xstrdup(p);
-               else
-                       BUG("should be able to skip past '%s' in '%s'!",
-                           prefix, old_branch_info.path);
        }
 
        if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {
@@ -1550,8 +1547,10 @@ static struct option *add_common_switch_branch_options(
 {
        struct option options[] = {
                OPT_BOOL('d', "detach", &opts->force_detach, N_("detach HEAD at named commit")),
-               OPT_SET_INT('t', "track",  &opts->track, N_("set upstream info for new branch"),
-                       BRANCH_TRACK_EXPLICIT),
+               OPT_CALLBACK_F('t', "track",  &opts->track, "(direct|inherit)",
+                       N_("set branch tracking configuration"),
+                       PARSE_OPT_OPTARG,
+                       parse_opt_tracking_mode),
                OPT__FORCE(&opts->force, N_("force checkout (throw away local modifications)"),
                           PARSE_OPT_NOCOMPLETE),
                OPT_STRING(0, "orphan", &opts->new_orphan_branch, N_("new-branch"), N_("new unparented branch")),
@@ -1636,11 +1635,11 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
        }
 
        if ((!!opts->new_branch + !!opts->new_branch_force + !!opts->new_orphan_branch) > 1)
-               die(_("-%c, -%c and --orphan are mutually exclusive"),
-                               cb_option, toupper(cb_option));
+               die(_("options '-%c', '-%c', and '%s' cannot be used together"),
+                       cb_option, toupper(cb_option), "--orphan");
 
        if (opts->overlay_mode == 1 && opts->patch_mode)
-               die(_("-p and --overlay are mutually exclusive"));
+               die(_("options '%s' and '%s' cannot be used together"), "-p", "--overlay");
 
        if (opts->checkout_index >= 0 || opts->checkout_worktree >= 0) {
                if (opts->checkout_index < 0)
@@ -1747,19 +1746,19 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
 
        if (opts->pathspec_from_file) {
                if (opts->pathspec.nr)
-                       die(_("--pathspec-from-file is incompatible with pathspec arguments"));
+                       die(_("'%s' and pathspec arguments cannot be used together"), "--pathspec-from-file");
 
                if (opts->force_detach)
-                       die(_("--pathspec-from-file is incompatible with --detach"));
+                       die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--detach");
 
                if (opts->patch_mode)
-                       die(_("--pathspec-from-file is incompatible with --patch"));
+                       die(_("options '%s' and '%s' cannot be used together"), "--pathspec-from-file", "--patch");
 
                parse_pathspec_file(&opts->pathspec, 0,
                                    0,
                                    prefix, opts->pathspec_from_file, opts->pathspec_file_nul);
        } else if (opts->pathspec_file_nul) {
-               die(_("--pathspec-file-nul requires --pathspec-from-file"));
+               die(_("the option '%s' requires '%s'"), "--pathspec-file-nul", "--pathspec-from-file");
        }
 
        opts->pathspec.recursive = 1;