hook: cleanup script
Prepare the 'preare-commit-msg' sample script for upcoming changes. Preparation includes removal of an example that has outlived it's purpose. The example is the one that comments the "Conflicts:" part of a merge commit message. It isn't relevant anymore as it's done by default since 261f315b ("merge & sequencer: turn "Conflicts:" hint into a comment", 2014-08-28). Further update the relevant comments from the sample script and update the documentation. Signed-off-by: Kaartic Sivaraam <kaarticsivaraam91196@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Kaartic Sivaraam committed
Jul 11, 2017 at 19:41 UTC
b22a3079466b72e8a8b76065d6c28efe7eea4b16
2 files changed
+10
-17
Documentation/githooks.txt
-3
@@ -121,9 +121,6 @@ it is not suppressed by the `--no-verify` option. A non-zero exit
121
means a failure of the hook and aborts the commit. It should not
122
be used as replacement for pre-commit hook.
123
124
-The sample `prepare-commit-msg` hook that comes with Git comments
125
-out the `Conflicts:` part of a merge's commit message.
126
-
124
commit-msg
125
~~~~~~~~~~
126
templates/hooks--prepare-commit-msg.sample
+10
-14
@@ -9,28 +9,24 @@
9
#
10
# To enable this hook, rename this file to "prepare-commit-msg".
11
12
-# This hook includes three examples. The first comments out the
13
-# "Conflicts:" part of a merge commit.
12
+# This hook includes two examples.
13
#
15
-# The second includes the output of "git diff --name-status -r"
14
+# The first includes the output of "git diff --name-status -r"
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
#
20
-# The third example adds a Signed-off-by line to the message, that can
19
+# The second example adds a Signed-off-by line to the message, that can
20
# still be edited. This is rarely a good idea.
21
23
-case "$2,$3" in
24
- merge,)
25
- @PERL_PATH@ -i.bak -ne 's/^/# /, s/^# #/#/ if /^Conflicts/ .. /#/; print' "$1" ;;
22
27
-# ,|template,)
28
-# @PERL_PATH@ -i.bak -pe '
29
-# print "\n" . `git diff --cached --name-status -r`
30
-# if /^#/ && $first++ == 0' "$1" ;;
31
-
32
- *) ;;
33
-esac
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
30
31
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
32
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"