summaryrefslogtreecommitdiff
path: root/t/t1416-ref-transaction-hooks.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t1416-ref-transaction-hooks.sh')
-rwxr-xr-xt/t1416-ref-transaction-hooks.sh27
1 files changed, 12 insertions, 15 deletions
diff --git a/t/t1416-ref-transaction-hooks.sh b/t/t1416-ref-transaction-hooks.sh
index 4e1e84a91f..085a7a46f2 100755
--- a/t/t1416-ref-transaction-hooks.sh
+++ b/t/t1416-ref-transaction-hooks.sh
@@ -8,7 +8,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
. ./test-lib.sh
test_expect_success setup '
- mkdir -p .git/hooks &&
test_commit PRE &&
PRE_OID=$(git rev-parse PRE) &&
test_commit POST &&
@@ -16,9 +15,8 @@ test_expect_success setup '
'
test_expect_success 'hook allows updating ref if successful' '
- test_when_finished "rm .git/hooks/reference-transaction" &&
git reset --hard PRE &&
- write_script .git/hooks/reference-transaction <<-\EOF &&
+ test_hook reference-transaction <<-\EOF &&
echo "$*" >>actual
EOF
cat >expect <<-EOF &&
@@ -30,9 +28,8 @@ test_expect_success 'hook allows updating ref if successful' '
'
test_expect_success 'hook aborts updating ref in prepared state' '
- test_when_finished "rm .git/hooks/reference-transaction" &&
git reset --hard PRE &&
- write_script .git/hooks/reference-transaction <<-\EOF &&
+ test_hook reference-transaction <<-\EOF &&
if test "$1" = prepared
then
exit 1
@@ -43,9 +40,9 @@ test_expect_success 'hook aborts updating ref in prepared state' '
'
test_expect_success 'hook gets all queued updates in prepared state' '
- test_when_finished "rm .git/hooks/reference-transaction actual" &&
+ test_when_finished "rm actual" &&
git reset --hard PRE &&
- write_script .git/hooks/reference-transaction <<-\EOF &&
+ test_hook reference-transaction <<-\EOF &&
if test "$1" = prepared
then
while read -r line
@@ -66,9 +63,9 @@ test_expect_success 'hook gets all queued updates in prepared state' '
'
test_expect_success 'hook gets all queued updates in committed state' '
- test_when_finished "rm .git/hooks/reference-transaction actual" &&
+ test_when_finished "rm actual" &&
git reset --hard PRE &&
- write_script .git/hooks/reference-transaction <<-\EOF &&
+ test_hook reference-transaction <<-\EOF &&
if test "$1" = committed
then
while read -r line
@@ -86,9 +83,9 @@ test_expect_success 'hook gets all queued updates in committed state' '
'
test_expect_success 'hook gets all queued updates in aborted state' '
- test_when_finished "rm .git/hooks/reference-transaction actual" &&
+ test_when_finished "rm actual" &&
git reset --hard PRE &&
- write_script .git/hooks/reference-transaction <<-\EOF &&
+ test_hook reference-transaction <<-\EOF &&
if test "$1" = aborted
then
while read -r line
@@ -115,11 +112,11 @@ test_expect_success 'interleaving hook calls succeed' '
git init --bare target-repo.git &&
- write_script target-repo.git/hooks/reference-transaction <<-\EOF &&
+ test_hook -C target-repo.git reference-transaction <<-\EOF &&
echo $0 "$@" >>actual
EOF
- write_script target-repo.git/hooks/update <<-\EOF &&
+ test_hook -C target-repo.git update <<-\EOF &&
echo $0 "$@" >>actual
EOF
@@ -140,7 +137,7 @@ test_expect_success 'hook does not get called on packing refs' '
# Pack references first such that we are in a known state.
git pack-refs --all &&
- write_script .git/hooks/reference-transaction <<-\EOF &&
+ test_hook reference-transaction <<-\EOF &&
echo "$@" >>actual
cat >>actual
EOF
@@ -166,7 +163,7 @@ test_expect_success 'deleting packed ref calls hook once' '
git update-ref refs/heads/to-be-deleted $POST_OID &&
git pack-refs --all &&
- write_script .git/hooks/reference-transaction <<-\EOF &&
+ test_hook reference-transaction <<-\EOF &&
echo "$@" >>actual
cat >>actual
EOF