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

[PATCH] Add option hooks.diffopts to customize change summary in post-receive-email

From
Jon Jensen <jon@endpoint.com>
Date
Aug 4, 2011, 03:36 UTC
Message-ID
<alpine.DEB.2.02.1108032117240.12142@ybpnyubfg6.ybpnyqbznva6>
In-Reply-To
<7vr552ba4e.fsf@alter.siamese.dyndns.org>

This makes it easy to customize the git diff-tree options, for example to include -p to include inline diffs.

It defaults to the current options "--stat --summary --find-copies-harder" and thus is backward-compatible.

Signed-off-by: Jon Jensen <jon@endpoint.com>
Improved-by: Junio C Hamano <gitster@pobox.com>
---
Thanks for the suggestion, Junio. It makes a lot of sense.
Jon
 contrib/hooks/post-receive-email |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 9c678e6..cd5664d 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -60,6 +60,11 @@
 #   email body. If not specified, there is no limit.
 #   Lines beyond the limit are suppressed and counted, and a final
 #   line is added indicating the number of suppressed lines.
+# hooks.diffopts
+#   Alternate options for the git diff-tree invocation that shows changes.
+#   Default is "--stat --summary --find-copies-harder". Add -p to those
+#   options to include a unified diff of changes in addition to the usual
+#   summary output.
 #
 # Notes
 # -----
@@ -447,7 +452,7 @@ generate_update_branch_email()
 	# non-fast-forward updates.
 	echo ""
 	echo "Summary of changes:"
-	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
+	git diff-tree $diffopts $oldrev..$newrev
 }
 
 #
@@ -724,6 +729,8 @@ envelopesender=$(git config hooks.envelopesender)
 emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
 custom_showrev=$(git config hooks.showrev)
 maxlines=$(git config hooks.emailmaxlines)
+diffopts=$(git config hooks.diffopts)
+: ${diffopts:="--stat --summary --find-copies-harder"}
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or
-- 
1.7.6.233.gd79bc
Previous: Junio C Hamano
Message 3 of 3 in “Add option hooks.emaildiff to include full diff in post-receive-email”
  1. Add option hooks.emaildiff to include full diff in post-receive-emailJon Jensen, Aug 3, 2011
  2. Junio C HamanoAug 3, 2011
  3. Add option hooks.diffopts to customize change summary in post-receive-emailJon Jensen, Aug 4, 2011

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.