git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
APAndy Parkins <andyparkins@gmail.com>
Date
Dec 21, 2006, 09:24 UTC
Message-ID
<200612210924.17357.andyparkins@gmail.com>
In-Reply-To
<7vejqufonm.fsf@assigned-by-dhcp.cox.net>

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@gmail.com>
---
 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
Previous: Johannes SchindelinNext: Junio C Hamano
Message 9 of 11 in “hooks/pre-commit: add example to add Signed-off-by line to message”
  1. hooks/pre-commit: add example to add Signed-off-by line to messageJohannes Schindelin, Nov 29, 2006
  2. Andy ParkinsDec 20, 2006
  3. hooks/pre-commit: add example to add Signed-off-by line to messageAndy Parkins, Dec 20, 2006
  4. Johannes SchindelinDec 20, 2006
  5. Junio C HamanoDec 20, 2006
  6. Johannes SchindelinDec 20, 2006
  7. Junio C HamanoDec 20, 2006
  8. Johannes SchindelinDec 21, 2006
  9. hooks/commit-msg: add example to add Signed-off-by line to messageAndy Parkins, Dec 21, 2006
  10. Junio C HamanoDec 22, 2006
  11. Andy ParkinsDec 22, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.