mailmap: plug memory leak in read_mailmap_blob()
[git/gitster.git] / t / t1350-config-hooks-path.sh
blobceeb7ac3a4745fd817dc601da93b836260fcf51a
1 #!/bin/sh
3 test_description='Test the core.hooksPath configuration variable'
5 TEST_PASSES_SANITIZE_LEAK=true
6 . ./test-lib.sh
8 test_expect_success 'set up a pre-commit hook in core.hooksPath' '
9 >actual &&
10 mkdir -p .git/custom-hooks &&
11 write_script .git/custom-hooks/pre-commit <<-\EOF &&
12 echo CUSTOM >>actual
13 EOF
14 test_hook --setup pre-commit <<-\EOF
15 echo NORMAL >>actual
16 EOF
19 test_expect_success 'Check that various forms of specifying core.hooksPath work' '
20 test_commit no_custom_hook &&
21 git config core.hooksPath .git/custom-hooks &&
22 test_commit have_custom_hook &&
23 git config core.hooksPath .git/custom-hooks/ &&
24 test_commit have_custom_hook_trailing_slash &&
25 git config core.hooksPath "$PWD/.git/custom-hooks" &&
26 test_commit have_custom_hook_abs_path &&
27 git config core.hooksPath "$PWD/.git/custom-hooks/" &&
28 test_commit have_custom_hook_abs_path_trailing_slash &&
29 cat >expect <<-\EOF &&
30 NORMAL
31 CUSTOM
32 CUSTOM
33 CUSTOM
34 CUSTOM
35 EOF
36 test_cmp expect actual
39 test_expect_success 'git rev-parse --git-path hooks' '
40 git config core.hooksPath .git/custom-hooks &&
41 git rev-parse --git-path hooks/abc >actual &&
42 test .git/custom-hooks/abc = "$(cat actual)"
45 test_expect_success 'core.hooksPath=/dev/null' '
46 git clone -c core.hooksPath=/dev/null . no-templates &&
47 value="$(git -C no-templates config --local core.hooksPath)" &&
48 # The Bash used by Git for Windows rewrites `/dev/null` to `nul`
49 { test /dev/null = "$value" || test nul = "$value"; }
52 test_done