summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2017-12-27 19:16:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-12-27 19:16:21 (GMT)
commite87f9fc9d4ead0ec7f98c9493a9f2ad8c41cd6ee (patch)
treeee27b22b0950137d8f450d1ac95ddb67714df241 /t
parent0da2ba4880f971de2782f2d4cfcd68f9148d2860 (diff)
parentade546be4786637ba039478d6f027becb1160803 (diff)
downloadgit-e87f9fc9d4ead0ec7f98c9493a9f2ad8c41cd6ee.zip
git-e87f9fc9d4ead0ec7f98c9493a9f2ad8c41cd6ee.tar.gz
git-e87f9fc9d4ead0ec7f98c9493a9f2ad8c41cd6ee.tar.bz2
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-xt/t2025-worktree-add.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/t/t2025-worktree-add.sh b/t/t2025-worktree-add.sh
index 6ce9b9c..1285668 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