Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Tan <pyokagan@gmail.com>2015-07-19 18:49:14 +0300
committerJunio C Hamano <gitster@pobox.com>2015-07-20 20:52:21 +0300
commit3bc6686b8687e3aa0331b37464ce25b609c3ec88 (patch)
tree98fc6a5abaeea22d309118ce6f15da13d43eeaac /t/t4150-am.sh
parentf26bdf2d98b6efbf02e65ef41a33b31cd3fbfcb9 (diff)
t4150: am with pre-applypatch hook
Since d1c5f2a (Add git-am, applymbox replacement., 2005-10-07), git-am.sg will invoke the pre-applypatch hook after applying the patch to the index, but before a commit is made. Should the hook exit with a non-zero status, git am will exit. 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/t4150-am.sh')
-rwxr-xr-xt/t4150-am.sh33
1 files changed, 33 insertions, 0 deletions
diff --git a/t/t4150-am.sh b/t/t4150-am.sh
index 7878e32e05..957c63c768 100755
--- a/t/t4150-am.sh
+++ b/t/t4150-am.sh
@@ -234,6 +234,39 @@ test_expect_success 'am with failing applypatch-msg hook' '
test_cmp_rev first HEAD
'
+test_expect_success 'am with pre-applypatch hook' '
+ test_when_finished "rm -f .git/hooks/pre-applypatch" &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout first &&
+ mkdir -p .git/hooks &&
+ write_script .git/hooks/pre-applypatch <<-\EOF &&
+ git diff first >diff.actual
+ exit 0
+ EOF
+ git am patch1 &&
+ test_path_is_missing .git/rebase-apply &&
+ git diff --exit-code second &&
+ test_cmp_rev second HEAD &&
+ git diff first..second >diff.expected &&
+ test_cmp diff.expected diff.actual
+'
+
+test_expect_success 'am with failing pre-applypatch hook' '
+ test_when_finished "rm -f .git/hooks/pre-applypatch" &&
+ rm -fr .git/rebase-apply &&
+ git reset --hard &&
+ git checkout first &&
+ mkdir -p .git/hooks &&
+ write_script .git/hooks/pre-applypatch <<-\EOF &&
+ exit 1
+ EOF
+ test_must_fail git am patch1 &&
+ test_path_is_dir .git/rebase-apply &&
+ git diff --exit-code second &&
+ 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" &&