Merge branch 'ps/ref-transaction-hook'
The logic to find the ref transaction hook script attempted to cache the path to the found hook without realizing that it needed to keep a copied value, as the API it used returned a transitory buffer space. This has been corrected. * ps/ref-transaction-hook: t1416: avoid hard-coded sha1 ids refs: fix interleaving hook calls with reference-transaction hook
This commit is contained in:
commit
5676db2612
2
refs.c
2
refs.c
@ -2044,7 +2044,7 @@ static int run_transaction_hook(struct ref_transaction *transaction,
|
||||
if (hook == &hook_not_found)
|
||||
return ret;
|
||||
if (!hook)
|
||||
hook = find_hook("reference-transaction");
|
||||
hook = xstrdup_or_null(find_hook("reference-transaction"));
|
||||
if (!hook) {
|
||||
hook = &hook_not_found;
|
||||
return ret;
|
||||
|
@ -7,6 +7,7 @@ test_description='reference transaction hooks'
|
||||
test_expect_success setup '
|
||||
mkdir -p .git/hooks &&
|
||||
test_commit PRE &&
|
||||
PRE_OID=$(git rev-parse PRE) &&
|
||||
test_commit POST &&
|
||||
POST_OID=$(git rev-parse POST)
|
||||
'
|
||||
@ -106,4 +107,30 @@ test_expect_success 'hook gets all queued updates in aborted state' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'interleaving hook calls succeed' '
|
||||
test_when_finished "rm -r target-repo.git" &&
|
||||
|
||||
git init --bare target-repo.git &&
|
||||
|
||||
write_script target-repo.git/hooks/reference-transaction <<-\EOF &&
|
||||
echo $0 "$@" >>actual
|
||||
EOF
|
||||
|
||||
write_script target-repo.git/hooks/update <<-\EOF &&
|
||||
echo $0 "$@" >>actual
|
||||
EOF
|
||||
|
||||
cat >expect <<-EOF &&
|
||||
hooks/update refs/tags/PRE $ZERO_OID $PRE_OID
|
||||
hooks/reference-transaction prepared
|
||||
hooks/reference-transaction committed
|
||||
hooks/update refs/tags/POST $ZERO_OID $POST_OID
|
||||
hooks/reference-transaction prepared
|
||||
hooks/reference-transaction committed
|
||||
EOF
|
||||
|
||||
git push ./target-repo.git PRE POST &&
|
||||
test_cmp expect target-repo.git/actual
|
||||
'
|
||||
|
||||
test_done
|
||||
|
Loading…
Reference in New Issue
Block a user