diff options
author | Junio C Hamano <gitster@pobox.com> | 2017-12-27 11:16:21 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2017-12-27 11:16:21 -0800 |
commit | e87f9fc9d4ead0ec7f98c9493a9f2ad8c41cd6ee (patch) | |
tree | ee27b22b0950137d8f450d1ac95ddb67714df241 /t | |
parent | 0da2ba4880f971de2782f2d4cfcd68f9148d2860 (diff) | |
parent | ade546be4786637ba039478d6f027becb1160803 (diff) | |
download | git-e87f9fc9d4ead0ec7f98c9493a9f2ad8c41cd6ee.tar.gz git-e87f9fc9d4ead0ec7f98c9493a9f2ad8c41cd6ee.tar.xz |
Merge branch 'es/worktree-checkout-hook'
"git worktree add" learned to run the post-checkout hook, just like
"git checkout" does, after the initial checkout.
* es/worktree-checkout-hook:
worktree: invoke post-checkout hook (unless --no-checkout)
Diffstat (limited to 't')
-rwxr-xr-x | t/t2025-worktree-add.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh index 6ce9b9c07..1285668cf 100755 --- a/t/t2025-worktree-add.sh +++ b/t/t2025-worktree-add.sh @@ -444,4 +444,33 @@ test_expect_success 'git worktree --no-guess-remote option overrides config' ' ) ' +post_checkout_hook () { + test_when_finished "rm -f .git/hooks/post-checkout" && + mkdir -p .git/hooks && + write_script .git/hooks/post-checkout <<-\EOF + echo $* >hook.actual + EOF +} + +test_expect_success '"add" invokes post-checkout hook (branch)' ' + post_checkout_hook && + printf "%s %s 1\n" $_z40 $(git rev-parse HEAD) >hook.expect && + git worktree add gumby && + test_cmp hook.expect hook.actual +' + +test_expect_success '"add" invokes post-checkout hook (detached)' ' + post_checkout_hook && + printf "%s %s 1\n" $_z40 $(git rev-parse HEAD) >hook.expect && + git worktree add --detach grumpy && + test_cmp hook.expect hook.actual +' + +test_expect_success '"add --no-checkout" suppresses post-checkout hook' ' + post_checkout_hook && + rm -f hook.actual && + git worktree add --no-checkout gloopy && + test_path_is_missing hook.actual +' + test_done |