Ram Gandikota
/
ABCD
A metronome using the FRDM K64F board
easy-connect/.git/hooks/prepare-commit-msg.sample@0:a7a43371b306, 2017-05-14 (annotated)
- Committer:
- ram54288
- Date:
- Sun May 14 18:40:18 2017 +0000
- Revision:
- 0:a7a43371b306
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
ram54288 | 0:a7a43371b306 | 1 | #!/bin/sh |
ram54288 | 0:a7a43371b306 | 2 | # |
ram54288 | 0:a7a43371b306 | 3 | # An example hook script to prepare the commit log message. |
ram54288 | 0:a7a43371b306 | 4 | # Called by "git commit" with the name of the file that has the |
ram54288 | 0:a7a43371b306 | 5 | # commit message, followed by the description of the commit |
ram54288 | 0:a7a43371b306 | 6 | # message's source. The hook's purpose is to edit the commit |
ram54288 | 0:a7a43371b306 | 7 | # message file. If the hook fails with a non-zero status, |
ram54288 | 0:a7a43371b306 | 8 | # the commit is aborted. |
ram54288 | 0:a7a43371b306 | 9 | # |
ram54288 | 0:a7a43371b306 | 10 | # To enable this hook, rename this file to "prepare-commit-msg". |
ram54288 | 0:a7a43371b306 | 11 | |
ram54288 | 0:a7a43371b306 | 12 | # This hook includes three examples. The first comments out the |
ram54288 | 0:a7a43371b306 | 13 | # "Conflicts:" part of a merge commit. |
ram54288 | 0:a7a43371b306 | 14 | # |
ram54288 | 0:a7a43371b306 | 15 | # The second includes the output of "git diff --name-status -r" |
ram54288 | 0:a7a43371b306 | 16 | # into the message, just before the "git status" output. It is |
ram54288 | 0:a7a43371b306 | 17 | # commented because it doesn't cope with --amend or with squashed |
ram54288 | 0:a7a43371b306 | 18 | # commits. |
ram54288 | 0:a7a43371b306 | 19 | # |
ram54288 | 0:a7a43371b306 | 20 | # The third example adds a Signed-off-by line to the message, that can |
ram54288 | 0:a7a43371b306 | 21 | # still be edited. This is rarely a good idea. |
ram54288 | 0:a7a43371b306 | 22 | |
ram54288 | 0:a7a43371b306 | 23 | case "$2,$3" in |
ram54288 | 0:a7a43371b306 | 24 | merge,) |
ram54288 | 0:a7a43371b306 | 25 | /usr/bin/perl -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;; |
ram54288 | 0:a7a43371b306 | 26 | |
ram54288 | 0:a7a43371b306 | 27 | # ,|template,) |
ram54288 | 0:a7a43371b306 | 28 | # /usr/bin/perl -i.bak -pe ' |
ram54288 | 0:a7a43371b306 | 29 | # print "\n" . `git diff --cached --name-status -r` |
ram54288 | 0:a7a43371b306 | 30 | # if /^#/ && $first++ == 0' "$1" ;; |
ram54288 | 0:a7a43371b306 | 31 | |
ram54288 | 0:a7a43371b306 | 32 | *) ;; |
ram54288 | 0:a7a43371b306 | 33 | esac |
ram54288 | 0:a7a43371b306 | 34 | |
ram54288 | 0:a7a43371b306 | 35 | # SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p') |
ram54288 | 0:a7a43371b306 | 36 | # grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1" |