3 test_description='check problems with relative GIT_DIR
5 This test creates a working tree state with a file and subdir:
7 top (committed several times)
8 subdir (a subdirectory)
10 It creates a commit-hook and tests it, then moves .git
11 into the subdir while keeping the worktree location,
12 and tries commits from the top and the subdir, checking
13 that the commit-hook still gets called.'
17 COMMIT_FILE="$(pwd)/output"
20 test_expect_success 'Setting up post-commit hook' '
21 mkdir -p .git/hooks &&
22 echo >.git/hooks/post-commit "#!/bin/sh
23 touch \"\${COMMIT_FILE}\"
24 echo Post commit hook was called." &&
25 chmod +x .git/hooks/post-commit'
27 test_expect_success 'post-commit hook used ordinarily' '
30 git commit -m initial &&
31 test -r "${COMMIT_FILE}"
34 rm -rf "${COMMIT_FILE}"
38 test_expect_success 'post-commit-hook created and used from top dir' '
40 git --git-dir subdir/.git add top &&
41 git --git-dir subdir/.git commit -m topcommit &&
42 test -r "${COMMIT_FILE}"
45 rm -rf "${COMMIT_FILE}"
47 test_expect_success 'post-commit-hook from sub dir' '
48 echo changed again >top &&
50 git --git-dir .git --work-tree .. add ../top &&
51 git --git-dir .git --work-tree .. commit -m subcommit &&
52 test -r "${COMMIT_FILE}"