Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/git/blob/master/t/t2050-git-dir-relative.sh # git [Ported from github.com/git/git] Sync with Git 2.56.1 Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `git / t / t2050-git-dir-relative.sh` 55 lines ยท 1341 bytes Raw Blame History 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 15 . ./test-lib.sh 16 17 COMMIT_FILE="$(pwd)/output" 18 export COMMIT_FILE 19 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' 26 27 test_expect_success 'post-commit hook used ordinarily' ' 28 echo initial >top && 29 git add top && 30 git commit -m initial && 31 test -r "${COMMIT_FILE}" 32 ' 33 34 rm -rf "${COMMIT_FILE}" 35 mkdir subdir 36 mv .git subdir 37 38 test_expect_success 'post-commit-hook created and used from top dir' ' 39 echo changed >top && 40 git --git-dir subdir/.git add top && 41 git --git-dir subdir/.git commit -m topcommit && 42 test -r "${COMMIT_FILE}" 43 ' 44 45 rm -rf "${COMMIT_FILE}" 46 47 test_expect_success 'post-commit-hook from sub dir' ' 48 echo changed again >top && 49 cd subdir && 50 git --git-dir .git --work-tree .. add ../top && 51 git --git-dir .git --work-tree .. commit -m subcommit && 52 test -r "${COMMIT_FILE}" 53 ' 54 55 test_done