]>
Commit | Line | Data |
---|---|---|
30c5cd31 DK |
1 | #!/bin/sh |
2 | ||
3 | test_description='check problems with relative GIT_DIR | |
4 | ||
5 | This test creates a working tree state with a file and subdir: | |
6 | ||
7 | top (committed several times) | |
8 | subdir (a subdirectory) | |
9 | ||
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.' | |
14 | ||
288a4806 | 15 | TEST_PASSES_SANITIZE_LEAK=true |
30c5cd31 DK |
16 | . ./test-lib.sh |
17 | ||
18 | COMMIT_FILE="$(pwd)/output" | |
19 | export COMMIT_FILE | |
20 | ||
21 | test_expect_success 'Setting up post-commit hook' ' | |
22 | mkdir -p .git/hooks && | |
23 | echo >.git/hooks/post-commit "#!/bin/sh | |
24 | touch \"\${COMMIT_FILE}\" | |
25 | echo Post commit hook was called." && | |
26 | chmod +x .git/hooks/post-commit' | |
27 | ||
28 | test_expect_success 'post-commit hook used ordinarily' ' | |
29 | echo initial >top && | |
a48fcd83 | 30 | git add top && |
0cb0e143 | 31 | git commit -m initial && |
30c5cd31 DK |
32 | test -r "${COMMIT_FILE}" |
33 | ' | |
34 | ||
35 | rm -rf "${COMMIT_FILE}" | |
36 | mkdir subdir | |
37 | mv .git subdir | |
38 | ||
39 | test_expect_success 'post-commit-hook created and used from top dir' ' | |
40 | echo changed >top && | |
41 | git --git-dir subdir/.git add top && | |
42 | git --git-dir subdir/.git commit -m topcommit && | |
43 | test -r "${COMMIT_FILE}" | |
44 | ' | |
45 | ||
46 | rm -rf "${COMMIT_FILE}" | |
47 | ||
48 | test_expect_success 'post-commit-hook from sub dir' ' | |
a48fcd83 | 49 | echo changed again >top && |
30c5cd31 DK |
50 | cd subdir && |
51 | git --git-dir .git --work-tree .. add ../top && | |
52 | git --git-dir .git --work-tree .. commit -m subcommit && | |
53 | test -r "${COMMIT_FILE}" | |
54 | ' | |
55 | ||
56 | test_done |