annotate BSseeker2/.git/hooks/prepare-commit-msg.sample @ 1:8b26adf64adc draft default tip

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