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>
Paul Tan committed
Jul 19, 2015 at 23:49 UTC
3ef4446bf23f7c7ecafb275f833b155608484146
1 file changed
+38
t/t4150-am.sh
+38
@@ -267,6 +267,44 @@ test_expect_success 'am with failing pre-applypatch hook' '
267
test_cmp_rev first HEAD
268
'
269
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
+
308
test_expect_success 'setup: new author and committer' '
309
GIT_AUTHOR_NAME="Another Thor" &&
310
GIT_AUTHOR_EMAIL="a.thor@example.com" &&