Skip to content

Commit 0ef1a4e

Browse files
Kaartic Sivaraamgitster
authored andcommitted
hook: add a simple first example
Add a simple example that replaces an outdated example that was removed. This ensures that there's at the least a simple example that illustrates what could be done using the hook just by enabling it. Also, update the documentation. Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent e1a4a28 commit 0ef1a4e

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

Documentation/githooks.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,9 @@ it is not suppressed by the `--no-verify` option. A non-zero exit
121121
means a failure of the hook and aborts the commit. It should not
122122
be used as replacement for pre-commit hook.
123123

124+
The sample `prepare-commit-msg` hook that comes with Git removes the
125+
help message found in the commented portion of the commit template.
126+
124127
commit-msg
125128
~~~~~~~~~~
126129

templates/hooks--prepare-commit-msg.sample

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,23 @@
99
#
1010
# To enable this hook, rename this file to "prepare-commit-msg".
1111

12-
# This hook includes two examples.
12+
# This hook includes three examples. The first one removes the
13+
# "# Please enter the commit message..." help message.
1314
#
14-
# The first includes the output of "git diff --name-status -r"
15+
# The second includes the output of "git diff --name-status -r"
1516
# into the message, just before the "git status" output. It is
1617
# commented because it doesn't cope with --amend or with squashed
1718
# commits.
1819
#
19-
# The second example adds a Signed-off-by line to the message, that can
20+
# The third example adds a Signed-off-by line to the message, that can
2021
# still be edited. This is rarely a good idea.
2122

2223
COMMIT_MSG_FILE=$1
2324
COMMIT_SOURCE=$2
2425
SHA1=$3
2526

27+
@PERL_PATH@ -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
28+
2629
# case "$COMMIT_SOURCE,$SHA1" in
2730
# ,|template,)
2831
# @PERL_PATH@ -i.bak -pe '

0 commit comments

Comments
 (0)