.git/hooks/commit-msg.sample
author Pascal Volk <user@localhost.localdomain.org>
Sun, 21 Nov 2021 22:04:40 +0000
changeset 762 0147c0a9ce2b
permissions -rwxr-xr-x
Added a README and the files of the empty vmm.git Simply `git pull` it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
762
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     1
#!/bin/sh
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     2
#
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     3
# An example hook script to check the commit log message.
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     4
# Called by "git commit" with one argument, the name of the file
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     5
# that has the commit message.  The hook should exit with non-zero
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     6
# status after issuing an appropriate message if it wants to stop the
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     7
# commit.  The hook is allowed to edit the commit message file.
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     8
#
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
     9
# To enable this hook, rename this file to "commit-msg".
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    10
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    11
# Uncomment the below to add a Signed-off-by line to the message.
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    12
# Doing this in a hook is a bad idea in general, but the prepare-commit-msg
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    13
# hook is more suited to it.
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    14
#
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    15
# SOB=$(git var GIT_AUTHOR_IDENT | sed -n 's/^\(.*>\).*$/Signed-off-by: \1/p')
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    16
# grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    17
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    18
# This example catches duplicate Signed-off-by lines.
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    19
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    20
test "" = "$(grep '^Signed-off-by: ' "$1" |
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    21
	 sort | uniq -c | sed -e '/^[ 	]*1[ 	]/d')" || {
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    22
	echo >&2 Duplicate Signed-off-by lines.
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    23
	exit 1
0147c0a9ce2b Added a README and the files of the empty vmm.git
Pascal Volk <user@localhost.localdomain.org>
parents:
diff changeset
    24
}