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

[PATCH v2 2/2] contrib/hooks/post-receive-email: Make revision display configurable

From
PHPete Harlan <pgit@pcharlan.com>
Date
Nov 4, 2008, 07:19 UTC
Message-ID
<1225783194-24640-3-git-send-email-pgit@pcharlan.com>
In-Reply-To
<1225783194-24640-2-git-send-email-pgit@pcharlan.com>

Add configuration option hooks.showrev, letting the user override how revisions will be shown in the commit email.

Signed-off-by: Pete Harlan <pgit@pcharlan.com>
---
 contrib/hooks/post-receive-email |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 2cd373d..28a3c0e 100644
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -38,6 +38,12 @@
 # hooks.emailprefix
 #   All emails have their subjects prefixed with this prefix, or "[SCM]"
 #   if emailprefix is unset, to aid filtering
+# hooks.showrev
+#   The shell command used to format each revision in the email, with
+#   "%s" replaced with the commit id.  Defaults to "git rev-list -1
+#   --pretty %s", displaying the commit id, author, date and log
+#   message.  To list full patches separated by a blank line, you
+#   could set this to "git show -C %s; echo".
 #
 # Notes
 # -----
@@ -610,7 +616,16 @@ show_new_revisions()
 	fi
 
 	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-	git rev-list --pretty --stdin $revspec
+	if [ -z "$custom_showrev" ]
+	then
+		git rev-list --pretty --stdin $revspec
+	else
+		git rev-list --stdin $revspec |
+		while read onerev
+		do
+			eval $(printf "$custom_showrev" $onerev)
+		done
+	fi
 }
 
 
@@ -650,6 +665,7 @@ recipients=$(git config hooks.mailinglist)
 announcerecipients=$(git config hooks.announcelist)
 envelopesender=$(git config hooks.envelopesender)
 emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
+custom_showrev=$(git config hooks.showrev)
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or
-- 
1.6.0.3.533.ge0502
Previous: Pete HarlanNext: Junio C Hamano
Message 3 of 4 in “post-receive-email configurable rev display”
  1. 0/2 post-receive-email configurable rev displayPete Harlan, Nov 4, 2008
  2. 1/2 contrib/hooks/post-receive-email: Put rev display in separate functionPete Harlan, Nov 4, 2008
  3. 2/2 contrib/hooks/post-receive-email: Make revision display configurablePete Harlan, Nov 4, 2008
  4. Junio C HamanoNov 4, 2008

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.