summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-07-19 23:49:13 +0800
committerJunio C Hamano <gitster@pobox.com>2015-07-20 10:52:13 -0700
commitf26bdf2d98b6efbf02e65ef41a33b31cd3fbfcb9 (patch)
tree0cfcb7421307f9c0a02c1a423040b1d7dc5a2b1f /t
parent9e2a113db95fb7e7eb3c74c1d0edc15be14fc0cf (diff)
downloadgit-f26bdf2d98b6efbf02e65ef41a33b31cd3fbfcb9.tar.gz
t4150: am with applypatch-msg hook
Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am will invoke the applypatch-msg hooks just after extracting the patch message. If the applypatch-msg hook exits with a non-zero status, git-am abort before even applying the patch to the index. 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>
Diffstat (limited to 't')
-rwxr-xr-xt/t4150-am.sh35
1 files changed, 35 insertions, 0 deletions
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index c1ec4d528e..7878e32e05 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -199,6 +199,41 @@ test_expect_success 'am applies patch e-mail with preceding whitespace' '
test "$(git rev-parse second^)" = "$(git rev-parse HEAD^)"
'
+test_expect_success 'am with applypatch-msg hook' '
+ test_when_finished "rm -f .git/hooks/applypatch-msg" &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout first &&
+ mkdir -p .git/hooks &&
+ write_script .git/hooks/applypatch-msg <<-\EOF &&
+ cat "$1" >actual-msg &&
+ echo hook-message >"$1"
+ EOF
+ git am patch1 &&
+ test_path_is_missing .git/rebase-apply &&
+ git diff --exit-code second &&
+ echo hook-message >expected &&
+ git log -1 --format=format:%B >actual &&
+ test_cmp expected actual &&
+ git log -1 --format=format:%B second >expected &&
+ test_cmp expected actual-msg
+'
+
+test_expect_success 'am with failing applypatch-msg hook' '
+ test_when_finished "rm -f .git/hooks/applypatch-msg" &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout first &&
+ mkdir -p .git/hooks &&
+ write_script .git/hooks/applypatch-msg <<-\EOF &&
+ exit 1
+ EOF
+ test_must_fail git am patch1 &&
+ test_path_is_dir .git/rebase-apply &&
+ git diff --exit-code first &&
+ test_cmp_rev first HEAD
+'
+
test_expect_success 'setup: new author and committer' '
GIT_AUTHOR_NAME="Another Thor" &&
GIT_AUTHOR_EMAIL="a.thor@example.com" &&