Donald Meyers / Mbed OS evan
Committer:
djmeyers
Date:
Sat Mar 18 22:37:16 2017 +0000
Revision:
0:06ee5f8a484a
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
djmeyers 0:06ee5f8a484a 1 #!/bin/sh
djmeyers 0:06ee5f8a484a 2 #
djmeyers 0:06ee5f8a484a 3 # An example hook script to prepare the commit log message.
djmeyers 0:06ee5f8a484a 4 # Called by "git commit" with the name of the file that has the
djmeyers 0:06ee5f8a484a 5 # commit message, followed by the description of the commit
djmeyers 0:06ee5f8a484a 6 # message's source. The hook's purpose is to edit the commit
djmeyers 0:06ee5f8a484a 7 # message file. If the hook fails with a non-zero status,
djmeyers 0:06ee5f8a484a 8 # the commit is aborted.
djmeyers 0:06ee5f8a484a 9 #
djmeyers 0:06ee5f8a484a 10 # To enable this hook, rename this file to "prepare-commit-msg".
djmeyers 0:06ee5f8a484a 11
djmeyers 0:06ee5f8a484a 12 # This hook includes three examples. The first comments out the
djmeyers 0:06ee5f8a484a 13 # "Conflicts:" part of a merge commit.
djmeyers 0:06ee5f8a484a 14 #
djmeyers 0:06ee5f8a484a 15 # The second includes the output of "git diff --name-status -r"
djmeyers 0:06ee5f8a484a 16 # into the message, just before the "git status" output. It is
djmeyers 0:06ee5f8a484a 17 # commented because it doesn't cope with --amend or with squashed
djmeyers 0:06ee5f8a484a 18 # commits.
djmeyers 0:06ee5f8a484a 19 #
djmeyers 0:06ee5f8a484a 20 # The third example adds a Signed-off-by line to the message, that can
djmeyers 0:06ee5f8a484a 21 # still be edited. This is rarely a good idea.
djmeyers 0:06ee5f8a484a 22
djmeyers 0:06ee5f8a484a 23 case "$2,$3" in
djmeyers 0:06ee5f8a484a 24 merge,)
djmeyers 0:06ee5f8a484a 25 /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
djmeyers 0:06ee5f8a484a 26
djmeyers 0:06ee5f8a484a 27 # ,|template,)
djmeyers 0:06ee5f8a484a 28 # /usr/bin/perl -i.bak -pe '
djmeyers 0:06ee5f8a484a 29 # print "\n" . `git diff --cached --name-status -r`
djmeyers 0:06ee5f8a484a 30 # if /^#/ && $first++ == 0' "$1" ;;
djmeyers 0:06ee5f8a484a 31
djmeyers 0:06ee5f8a484a 32 *) ;;
djmeyers 0:06ee5f8a484a 33 esac
djmeyers 0:06ee5f8a484a 34
djmeyers 0:06ee5f8a484a 35 # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
djmeyers 0:06ee5f8a484a 36 # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"