t / t1350-config-hooks-path.shon commit test-reach: test get_merge_bases_many (324dec0)
   1#!/bin/sh
   2
   3test_description='Test the core.hooksPath configuration variable'
   4
   5. ./test-lib.sh
   6
   7test_expect_success 'set up a pre-commit hook in core.hooksPath' '
   8        mkdir -p .git/custom-hooks .git/hooks &&
   9        write_script .git/custom-hooks/pre-commit <<-\EOF &&
  10        echo CUSTOM >>actual
  11        EOF
  12        write_script .git/hooks/pre-commit <<-\EOF
  13        echo NORMAL >>actual
  14        EOF
  15'
  16
  17test_expect_success 'Check that various forms of specifying core.hooksPath work' '
  18        test_commit no_custom_hook &&
  19        git config core.hooksPath .git/custom-hooks &&
  20        test_commit have_custom_hook &&
  21        git config core.hooksPath .git/custom-hooks/ &&
  22        test_commit have_custom_hook_trailing_slash &&
  23        git config core.hooksPath "$PWD/.git/custom-hooks" &&
  24        test_commit have_custom_hook_abs_path &&
  25        git config core.hooksPath "$PWD/.git/custom-hooks/" &&
  26        test_commit have_custom_hook_abs_path_trailing_slash &&
  27        cat >expect <<-\EOF &&
  28        NORMAL
  29        CUSTOM
  30        CUSTOM
  31        CUSTOM
  32        CUSTOM
  33        EOF
  34        test_cmp expect actual
  35'
  36
  37test_expect_success 'git rev-parse --git-path hooks' '
  38        git config core.hooksPath .git/custom-hooks &&
  39        git rev-parse --git-path hooks/abc >actual &&
  40        test .git/custom-hooks/abc = "$(cat actual)"
  41'
  42
  43test_done