[PATCH] hooks/commit-msg: add example to add Signed-off-by line to message

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



After checking to see if the commit message already has the target
signed-off-by (for example in --amend commits), this patch generates a
signed off by line from the repository owner and adds it to the commit
message.

Based on Johannes Schindelin's earlier patch to perform the same
function.

Originally, this was done in the pre-commit hook but Junio pointed out
that the commit-msg hook allows the message to be edited.  This has the
aditional advantage that the commit-msg hook gets passed the name of the
message file as a parameter, so it doesn't have to figure out GIT_DIR for
itself.

Signed-off-by: Andy Parkins <andyparkins@xxxxxxxxx>
---
 templates/hooks--commit-msg |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/templates/hooks--commit-msg b/templates/hooks--commit-msg
index 0b906ca..ce76bdf 100644
--- a/templates/hooks--commit-msg
+++ b/templates/hooks--commit-msg
@@ -8,6 +8,11 @@
 #
 # To enable this hook, make this file executable.
 
+# Uncomment the below to add a Signed-off-by line to the message.
+#SOB=$(git var GIT_AUTHOR_IDENT | \
+#	sed -n "s/^\(.*\) [0-9]\+ [-+][0-9]\+$/Signed-off-by: \1/p")
+#grep -qs "^$SOB" "$1" || echo "$SOB" >> "$1"
+
 # This example catches duplicate Signed-off-by lines.
 
 test "" = "$(grep '^Signed-off-by: ' "$1" |
-- 
1.4.4.2.g120e3

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]