hook: cleanup script
[git/git.git] / templates / hooks--prepare-commit-msg.sample
CommitLineData
8089c85b
PB
1#!/bin/sh
2#
3# An example hook script to prepare the commit log message.
100e762a 4# Called by "git commit" with the name of the file that has the
8089c85b
PB
5# commit message, followed by the description of the commit
6# message's source. The hook's purpose is to edit the commit
7# message file. If the hook fails with a non-zero status,
8# the commit is aborted.
9#
f98f8cba 10# To enable this hook, rename this file to "prepare-commit-msg".
8089c85b 11
b22a3079 12# This hook includes two examples.
8089c85b 13#
b22a3079 14# The first includes the output of "git diff --name-status -r"
8089c85b
PB
15# into the message, just before the "git status" output. It is
16# commented because it doesn't cope with --amend or with squashed
17# commits.
18#
b22a3079 19# The second example adds a Signed-off-by line to the message, that can
8089c85b
PB
20# still be edited. This is rarely a good idea.
21
8089c85b 22
b22a3079
KS
23# case "$2,$3" in
24# ,|template,)
25# @PERL_PATH@ -i.bak -pe '
26# print "\n" . `git diff --cached --name-status -r`
27# if /^#/ && $first++ == 0' "$1" ;;
28# *) ;;
29# esac
8089c85b
PB
30
31# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
32# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"