summaryrefslogtreecommitdiffstats
path: root/vendor/gix/src/assets/init/hooks/applypatch-msg.sample
blob: 945f2f6b3d854b0b3f4f26d66d96c71cd9d1b975 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/sh
# A sample hook to check commit messages created by `git am`
###########################################################
#
# When you receive a patch via email, the `git am` command is commonly used to apply
# that patch. During the `git am` process, the `applypatch-msg` hook is executed before
# creating the commit. Its purpose is to validate and modify the commit log message
# before the patch is applied as a commit in your Git repository.
#
# This script serves as an example to validate that the commit message introduced by
# the patch from an email would pass the `commit-msg` hook, which would be executed
# if you had created the commit yourself.
#
# This hook is the first and followed up by `pre-applypatch` and `post-applypatch`.
#
# To enable this hook remove the `.sample` suffix from this file entirely.

# Retrieve the path of the commit-msg hook script.
commitmsg="$(git rev-parse --git-path hooks/commit-msg)"

# If the commit-msg hook script is executable, execute it and pass any command-line arguments to it.
test -x "$commitmsg" && exec "$commitmsg" ${1+"$@"}

# Be sure to exit without error if `exec` isn't called.
: