Skip to content

Commit 3ef4446

Browse files
pyokagangitster
authored andcommitted
t4150: am with post-applypatch hook
Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am.sh will invoke the post-applypatch hook after the patch is applied and a commit is made. The exit code of the hook is ignored. Add tests for this hook. Helped-by: Junio C Hamano <gitster@pobox.com> Reviewed-by: Stefan Beller <sbeller@google.com> Reviewed-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Paul Tan <pyokagan@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3bc6686 commit 3ef4446

1 file changed

Lines changed: 38 additions & 0 deletions

File tree

t/t4150-am.sh

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,44 @@ test_expect_success 'am with failing pre-applypatch hook' '
267267
test_cmp_rev first HEAD
268268
'
269269

270+
test_expect_success 'am with post-applypatch hook' '
271+
test_when_finished "rm -f .git/hooks/post-applypatch" &&
272+
rm -fr .git/rebase-apply &&
273+
git reset --hard &&
274+
git checkout first &&
275+
mkdir -p .git/hooks &&
276+
write_script .git/hooks/post-applypatch <<-\EOF &&
277+
git rev-parse HEAD >head.actual
278+
git diff second >diff.actual
279+
exit 0
280+
EOF
281+
git am patch1 &&
282+
test_path_is_missing .git/rebase-apply &&
283+
test_cmp_rev second HEAD &&
284+
git rev-parse second >head.expected &&
285+
test_cmp head.expected head.actual &&
286+
git diff second >diff.expected &&
287+
test_cmp diff.expected diff.actual
288+
'
289+
290+
test_expect_success 'am with failing post-applypatch hook' '
291+
test_when_finished "rm -f .git/hooks/post-applypatch" &&
292+
rm -fr .git/rebase-apply &&
293+
git reset --hard &&
294+
git checkout first &&
295+
mkdir -p .git/hooks &&
296+
write_script .git/hooks/post-applypatch <<-\EOF &&
297+
git rev-parse HEAD >head.actual
298+
exit 1
299+
EOF
300+
git am patch1 &&
301+
test_path_is_missing .git/rebase-apply &&
302+
git diff --exit-code second &&
303+
test_cmp_rev second HEAD &&
304+
git rev-parse second >head.expected &&
305+
test_cmp head.expected head.actual
306+
'
307+
270308
test_expect_success 'setup: new author and committer' '
271309
GIT_AUTHOR_NAME="Another Thor" &&
272310
GIT_AUTHOR_EMAIL="a.thor@example.com" &&

0 commit comments

Comments
 (0)