struct strvec *env,
const char *work_tree)
{
- struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
+ struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL;
+
opt.invoked_hook = invoked_hook;
- strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
strvec_pushv(&opt.env, env->v);
+ strvec_pushf(&opt.env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
strvec_push(&opt.args, hash_to_hex(hash));
if (run_hooks_opt(the_repository, push_to_checkout_hook, &opt))
return "push-to-checkout hook declined";
)
'
+ test_expect_success 'denyCurrentBranch and core.worktree' '
+ test_when_finished "rm -fr cloned cloned.git" &&
+ git clone --separate-git-dir cloned.git . cloned &&
+ git --git-dir cloned.git config receive.denyCurrentBranch updateInstead &&
+ git --git-dir cloned.git config core.worktree "$PWD/cloned" &&
+ test_commit raspberry &&
+ git push cloned.git HEAD:main &&
+ test_path_exists cloned/raspberry.t &&
+ test_must_fail git push --delete cloned.git main
+ '
+
test_expect_success 'denyCurrentBranch and worktrees' '
+ test_when_finished "rm -fr cloned && git worktree remove --force new-wt" &&
git worktree add new-wt &&
git clone . cloned &&
test_commit -C cloned first &&