submodule.c: migrate diff output to use emit_diff_symbol
[gitweb.git] / t / t9001-send-email.sh
index 60a80f60b2685c461f80cdbf4256eb17dc18b85b..d1e4e8ad19f3d3e005e177b98e4eee16f4ef1461 100755 (executable)
@@ -1913,4 +1913,52 @@ test_expect_success $PREREQ 'leading and trailing whitespaces are removed' '
        test_cmp expected-list actual-list
 '
 
+test_expect_success $PREREQ 'invoke hook' '
+       mkdir -p .git/hooks &&
+
+       write_script .git/hooks/sendemail-validate <<-\EOF &&
+       # test that we have the correct environment variable, pwd, and
+       # argument
+       case "$GIT_DIR" in
+       *.git)
+               true
+               ;;
+       *)
+               false
+               ;;
+       esac &&
+       test -f 0001-add-master.patch &&
+       grep "add master" "$1"
+       EOF
+
+       mkdir subdir &&
+       (
+               # Test that it works even if we are not at the root of the
+               # working tree
+               cd subdir &&
+               git send-email \
+                       --from="Example <nobody@example.com>" \
+                       --to=nobody@example.com \
+                       --smtp-server="$(pwd)/../fake.sendmail" \
+                       ../0001-add-master.patch &&
+
+               # Verify error message when a patch is rejected by the hook
+               sed -e "s/add master/x/" ../0001-add-master.patch >../another.patch &&
+               git send-email \
+                       --from="Example <nobody@example.com>" \
+                       --to=nobody@example.com \
+                       --smtp-server="$(pwd)/../fake.sendmail" \
+                       ../another.patch 2>err
+               test_i18ngrep "rejected by sendemail-validate hook" err
+       )
+'
+
+test_expect_success $PREREQ 'test that send-email works outside a repo' '
+       nongit git send-email \
+               --from="Example <nobody@example.com>" \
+               --to=nobody@example.com \
+               --smtp-server="$(pwd)/fake.sendmail" \
+               "$(pwd)/0001-add-master.patch"
+'
+
 test_done