]> git.ipfire.org Git - thirdparty/git.git/blame - t/t2050-git-dir-relative.sh
The third batch
[thirdparty/git.git] / t / t2050-git-dir-relative.sh
CommitLineData
30c5cd31
DK
1#!/bin/sh
2
3test_description='check problems with relative GIT_DIR
4
5This test creates a working tree state with a file and subdir:
6
7 top (committed several times)
8 subdir (a subdirectory)
9
10It creates a commit-hook and tests it, then moves .git
11into the subdir while keeping the worktree location,
12and tries commits from the top and the subdir, checking
13that the commit-hook still gets called.'
14
288a4806 15TEST_PASSES_SANITIZE_LEAK=true
30c5cd31
DK
16. ./test-lib.sh
17
18COMMIT_FILE="$(pwd)/output"
19export COMMIT_FILE
20
21test_expect_success 'Setting up post-commit hook' '
22mkdir -p .git/hooks &&
23echo >.git/hooks/post-commit "#!/bin/sh
24touch \"\${COMMIT_FILE}\"
25echo Post commit hook was called." &&
26chmod +x .git/hooks/post-commit'
27
28test_expect_success 'post-commit hook used ordinarily' '
29echo initial >top &&
a48fcd83 30git add top &&
0cb0e143 31git commit -m initial &&
30c5cd31
DK
32test -r "${COMMIT_FILE}"
33'
34
35rm -rf "${COMMIT_FILE}"
36mkdir subdir
37mv .git subdir
38
39test_expect_success 'post-commit-hook created and used from top dir' '
40echo changed >top &&
41git --git-dir subdir/.git add top &&
42git --git-dir subdir/.git commit -m topcommit &&
43test -r "${COMMIT_FILE}"
44'
45
46rm -rf "${COMMIT_FILE}"
47
48test_expect_success 'post-commit-hook from sub dir' '
a48fcd83 49echo changed again >top &&
30c5cd31
DK
50cd subdir &&
51git --git-dir .git --work-tree .. add ../top &&
52git --git-dir .git --work-tree .. commit -m subcommit &&
53test -r "${COMMIT_FILE}"
54'
55
56test_done