t / t2050-git-dir-relative.shon commit refs.c: remove ref_transaction_rollback (026bd1d)
   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
  15. ./test-lib.sh
  16
  17COMMIT_FILE="$(pwd)/output"
  18export COMMIT_FILE
  19
  20test_expect_success 'Setting up post-commit hook' '
  21mkdir -p .git/hooks &&
  22echo >.git/hooks/post-commit "#!/bin/sh
  23touch \"\${COMMIT_FILE}\"
  24echo Post commit hook was called." &&
  25chmod +x .git/hooks/post-commit'
  26
  27test_expect_success 'post-commit hook used ordinarily' '
  28echo initial >top &&
  29git add top &&
  30git commit -m initial &&
  31test -r "${COMMIT_FILE}"
  32'
  33
  34rm -rf "${COMMIT_FILE}"
  35mkdir subdir
  36mv .git subdir
  37
  38test_expect_success 'post-commit-hook created and used from top dir' '
  39echo changed >top &&
  40git --git-dir subdir/.git add top &&
  41git --git-dir subdir/.git commit -m topcommit &&
  42test -r "${COMMIT_FILE}"
  43'
  44
  45rm -rf "${COMMIT_FILE}"
  46
  47test_expect_success 'post-commit-hook from sub dir' '
  48echo changed again >top &&
  49cd subdir &&
  50git --git-dir .git --work-tree .. add ../top &&
  51git --git-dir .git --work-tree .. commit -m subcommit &&
  52test -r "${COMMIT_FILE}"
  53'
  54
  55test_done