]> 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 ec1c59ba53cd62cafee3688ff2fa6f14bcc78f0f..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);
@@ -505,7 +501,7 @@ static int add(int ac, const char **av, const char *prefix)
        if (!!opts.detach + !!new_branch + !!new_branch_force > 1)
                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)