]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/worktree.c
Merge branch 'en/fetch-negotiation-default-fix'
[thirdparty/git.git] / builtin / worktree.c
index a396cfdc64e4a48f0f56ef2db6a359de43c3017a..0d0809276fe1b566140ce2f75a704c06cd0aa690 100644 (file)
@@ -382,21 +382,17 @@ done:
         * is_junk is cleared, but do return appropriate code when hook fails.
         */
        if (!ret && opts->checkout) {
-               const char *hook = find_hook("post-checkout");
-               if (hook) {
-                       const char *env[] = { "GIT_DIR", "GIT_WORK_TREE", NULL };
-                       struct child_process cp = CHILD_PROCESS_INIT;
-                       cp.no_stdin = 1;
-                       cp.stdout_to_stderr = 1;
-                       cp.dir = path;
-                       strvec_pushv(&cp.env_array, env);
-                       cp.trace2_hook_name = "post-checkout";
-                       strvec_pushl(&cp.args, absolute_path(hook),
-                                    oid_to_hex(null_oid()),
-                                    oid_to_hex(&commit->object.oid),
-                                    "1", NULL);
-                       ret = run_command(&cp);
-               }
+               struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
+
+               strvec_pushl(&opt.env, "GIT_DIR", "GIT_WORK_TREE", NULL);
+               strvec_pushl(&opt.args,
+                            oid_to_hex(null_oid()),
+                            oid_to_hex(&commit->object.oid),
+                            "1",
+                            NULL);
+               opt.dir = path;
+
+               ret = run_hooks_opt("post-checkout", &opt);
        }
 
        strvec_clear(&child_env);
@@ -503,9 +499,9 @@ static int add(int ac, const char **av, const char *prefix)
        opts.checkout = 1;
        ac = parse_options(ac, av, prefix, options, worktree_usage, 0);
        if (!!opts.detach + !!new_branch + !!new_branch_force > 1)
-               die(_("-b, -B, and --detach are mutually exclusive"));
+               die(_("options '%s', '%s', and '%s' cannot be used together"), "-b", "-B", "--detach");
        if (lock_reason && !keep_locked)
-               die(_("--reason requires --lock"));
+               die(_("the option '%s' requires '%s'"), "--reason", "--lock");
        if (lock_reason)
                opts.keep_locked = lock_reason;
        else if (keep_locked)
@@ -699,7 +695,7 @@ static int list(int ac, const char **av, const char *prefix)
        if (ac)
                usage_with_options(worktree_usage, options);
        else if (verbose && porcelain)
-               die(_("--verbose and --porcelain are mutually exclusive"));
+               die(_("options '%s' and '%s' cannot be used together"), "--verbose", "--porcelain");
        else {
                struct worktree **worktrees = get_worktrees();
                int path_maxlen = 0, abbrev = DEFAULT_ABBREV, i;