git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Add option hooks.emaildiff to include full diff in post-receive-email.
@ 2008-08-11 21:01 Jon Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Jensen @ 2008-08-11 21:01 UTC (permalink / raw)
  To: git; +Cc: Jon Jensen

I've always found that a very important part of receiving email
notification of commits is being able to read the diff inline,
easily, where I can reply and quote the diff and make comments.
It's similar to the reason patches sent to the Git mailing list
need to be inline, not attachments.

Since post-receive-email didn't have that option, I added it as a
boolean config variable, hooks.emaildiff.
---
 contrib/hooks/post-receive-email |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 4136895..07351cc 100644
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -38,6 +38,9 @@
 # hooks.emailprefix
 #   All emails have their subjects prefixed with this prefix, or "[SCM]"
 #   if emailprefix is unset, to aid filtering
+# hooks.emaildiff
+#   If set, then a full diff of changes is sent in addition to the default
+#   summary output.
 #
 # Notes
 # -----
@@ -410,8 +413,13 @@ generate_update_branch_email()
 	# - including the undoing of previous revisions in the case of
 	# non-fast forward updates.
 	echo ""
-	echo "Summary of changes:"
-	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
+	if [ -n "$emaildiff" ]; then
+		echo "Summary of changes and diff:"
+		git diff-tree --find-copies-harder --stat --summary -p $oldrev..$newrev
+	else
+		echo "Summary of changes:"
+		git diff-tree --find-copies-harder --stat --summary $oldrev..$newrev
+	fi
 }
 
 #
@@ -627,6 +635,7 @@ recipients=$(git config hooks.mailinglist)
 announcerecipients=$(git config hooks.announcelist)
 envelopesender=$(git config hooks.envelopesender)
 emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
+emaildiff=$(git config hooks.emaildiff)
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or
-- 
1.6.0.rc2.2.gd827

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] Add option hooks.emaildiff to include full diff in post-receive-email.
@ 2008-08-11 21:20 Jon Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Jensen @ 2008-08-11 21:20 UTC (permalink / raw)
  To: git; +Cc: andyparkins, Jon Jensen

(I forgot to sign off the first time.)

I've always found that a very important part of receiving email
notification of commits is being able to read the diff inline,
easily, where I can reply and quote the diff and make comments.
It's similar to the reason patches sent to the Git mailing list
need to be inline, not attachments.

Since post-receive-email didn't have that option, I added it as a
boolean config variable, hooks.emaildiff.

Signed-off-by: Jon Jensen <jon@endpoint.com>
---
 contrib/hooks/post-receive-email |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 4136895..07351cc 100644
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -38,6 +38,9 @@
 # hooks.emailprefix
 #   All emails have their subjects prefixed with this prefix, or "[SCM]"
 #   if emailprefix is unset, to aid filtering
+# hooks.emaildiff
+#   If set, then a full diff of changes is sent in addition to the default
+#   summary output.
 #
 # Notes
 # -----
@@ -410,8 +413,13 @@ generate_update_branch_email()
 	# - including the undoing of previous revisions in the case of
 	# non-fast forward updates.
 	echo ""
-	echo "Summary of changes:"
-	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
+	if [ -n "$emaildiff" ]; then
+		echo "Summary of changes and diff:"
+		git diff-tree --find-copies-harder --stat --summary -p $oldrev..$newrev
+	else
+		echo "Summary of changes:"
+		git diff-tree --find-copies-harder --stat --summary $oldrev..$newrev
+	fi
 }
 
 #
@@ -627,6 +635,7 @@ recipients=$(git config hooks.mailinglist)
 announcerecipients=$(git config hooks.announcelist)
 envelopesender=$(git config hooks.envelopesender)
 emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
+emaildiff=$(git config hooks.emaildiff)
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or
-- 
1.6.0.rc2.2.gd827

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] Add option hooks.emaildiff to include full diff in post-receive-email
@ 2011-08-03  3:34 Jon Jensen
  2011-08-03 18:52 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jon Jensen @ 2011-08-03  3:34 UTC (permalink / raw)
  To: git

I've always found that a very important part of receiving email
notification of commits is being able to read the diff inline,
easily, where I can reply and quote the diff and make comments.
It's similar to the reason patches sent to the Git mailing list
need to be inline, not attachments.

Since post-receive-email didn't have that option, this adds it as a
boolean config variable, hooks.emaildiff.

Signed-off-by: Jon Jensen <jon@endpoint.com>
---
 contrib/hooks/post-receive-email |   13 +++++++++++--
 1 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 21989fc..5b9b26d 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -60,6 +60,9 @@
 #   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.emaildiff
+#   If set, then a full diff of changes is sent in addition to the default
+#   summary output.
 #
 # Notes
 # -----
@@ -445,8 +448,13 @@ generate_update_branch_email()
 	# - including the undoing of previous revisions in the case of
 	# non-fast-forward updates.
 	echo ""
-	echo "Summary of changes:"
-	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
+	if [ -n "$emaildiff" ]; then
+		echo "Summary of changes and diff:"
+		git diff-tree --stat --summary --find-copies-harder -p $oldrev..$newrev
+	else
+		echo "Summary of changes:"
+		git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
+	fi
 }
 
 #
@@ -723,6 +731,7 @@ envelopesender=$(git config hooks.envelopesender)
 emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')
 custom_showrev=$(git config hooks.showrev)
 maxlines=$(git config hooks.emailmaxlines)
+emaildiff=$(git config hooks.emaildiff)
 
 # --- Main loop
 # Allow dual mode: run from the command line just like the update hook, or
-- 
1.7.6.233.gd79bc

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] Add option hooks.emaildiff to include full diff in post-receive-email
  2011-08-03  3:34 [PATCH] Add option hooks.emaildiff to include full diff in post-receive-email Jon Jensen
@ 2011-08-03 18:52 ` Junio C Hamano
  2011-08-04  3:36   ` [PATCH] Add option hooks.diffopts to customize change summary " Jon Jensen
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2011-08-03 18:52 UTC (permalink / raw)
  To: Jon Jensen; +Cc: git

Jon Jensen <jon@endpoint.com> writes:

> -	echo "Summary of changes:"
> -	git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
> +	if [ -n "$emaildiff" ]; then
> +		echo "Summary of changes and diff:"
> +		git diff-tree --stat --summary --find-copies-harder -p $oldrev..$newrev
> +	else
> +		echo "Summary of changes:"
> +		git diff-tree --stat --summary --find-copies-harder $oldrev..$newrev
> +	fi

Depending on the project, people may want to customize other aspects of
the summary generation, e.g. rejecting the overhead of -f-c-h.

Why not do it like this intead?

	diffopts=$(git config hooks.diffopts)
	: ${diffopts:="--stat --summary --find-copies-harder"}
        
	echo "Summary of changes:"
        git diff-tree $diffopts $oldrev..$newrev

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH] Add option hooks.diffopts to customize change summary in post-receive-email
  2011-08-03 18:52 ` Junio C Hamano
@ 2011-08-04  3:36   ` Jon Jensen
  0 siblings, 0 replies; 5+ messages in thread
From: Jon Jensen @ 2011-08-04  3:36 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-08-04  3:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-03  3:34 [PATCH] Add option hooks.emaildiff to include full diff in post-receive-email Jon Jensen
2011-08-03 18:52 ` Junio C Hamano
2011-08-04  3:36   ` [PATCH] Add option hooks.diffopts to customize change summary " Jon Jensen
  -- strict thread matches above, loose matches on Subject: below --
2008-08-11 21:20 [PATCH] Add option hooks.emaildiff to include full diff " Jon Jensen
2008-08-11 21:01 Jon Jensen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).