Git development
 help / color / mirror / Atom feed
* [PATCH v2 0/2] post-receive-email configurable rev display
       [not found] <7v7i7kthkc.fsf@gitster.siamese.dyndns.org>
@ 2008-11-04  7:19 ` Pete Harlan
  2008-11-04 23:55   ` Junio C Hamano
  2008-11-04  7:19 ` [PATCH v2 1/2] contrib/hooks/post-receive-email: Put rev display in separate function Pete Harlan
  2008-11-04  7:19 ` [PATCH v2 2/2] contrib/hooks/post-receive-email: Make revision display configurable Pete Harlan
  2 siblings, 1 reply; 4+ messages in thread
From: Pete Harlan @ 2008-11-04  7:19 UTC (permalink / raw)
  To: Andy Parkins, git; +Cc: Pete Harlan

This is the second version of the user-configurable revision display
patch.  The first version decreased the efficiency of the default
case, while this avoids it thanks to a suggestion by Junio.

The first version of this patch also failed to customize the display
of revisions included in newly-created branches; this version displays
those revisions in the same manner as for updated branches.

The two places (new vs. updated branches) where the original code
displayed revisions used similar code.  The first patch in this series
factors that out to a separate routine that handles both cases, in
order to avoid duplicating the code introduced in the second patch.

Pete Harlan (2):
  contrib/hooks/post-receive-email: Put rev display in separate
    function
  contrib/hooks/post-receive-email: Make revision display configurable

 contrib/hooks/post-receive-email |   57 ++++++++++++++++++++++++++++++++------
 1 files changed, 48 insertions(+), 9 deletions(-)

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

* [PATCH v2 1/2] contrib/hooks/post-receive-email: Put rev display in separate function
       [not found] <7v7i7kthkc.fsf@gitster.siamese.dyndns.org>
  2008-11-04  7:19 ` [PATCH v2 0/2] post-receive-email configurable rev display Pete Harlan
@ 2008-11-04  7:19 ` Pete Harlan
  2008-11-04  7:19 ` [PATCH v2 2/2] contrib/hooks/post-receive-email: Make revision display configurable Pete Harlan
  2 siblings, 0 replies; 4+ messages in thread
From: Pete Harlan @ 2008-11-04  7:19 UTC (permalink / raw)
  To: Andy Parkins, git; +Cc: Pete Harlan

The display of a revision in an email-appropriate format is done in
two places with similar code.  In preparation for making that display
more complex, move it into a separate function that handles both cases.

Signed-off-by: Pete Harlan <pgit@pcharlan.com>
---
 contrib/hooks/post-receive-email |   41 +++++++++++++++++++++++++++++--------
 1 files changed, 32 insertions(+), 9 deletions(-)

diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index 4136895..2cd373d 100644
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -224,13 +224,7 @@ generate_create_branch_email()
 	echo ""
 
 	echo $LOGBEGIN
-	# This shows all log entries that are not already covered by
-	# another ref - i.e. commits that are now accessible from this
-	# ref that were previously not accessible
-	# (see generate_update_branch_email for the explanation of this
-	# command)
-	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-	git rev-list --pretty --stdin $newrev
+	show_new_revisions
 	echo $LOGEND
 }
 
@@ -390,8 +384,7 @@ generate_update_branch_email()
 
 		echo ""
 		echo $LOGBEGIN
-		git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
-		git rev-list --pretty --stdin $oldrev..$newrev
+		show_new_revisions
 
 		# XXX: Need a way of detecting whether git rev-list actually
 		# outputted anything, so that we can issue a "no new
@@ -591,6 +584,36 @@ generate_delete_general_email()
 	echo $LOGEND
 }
 
+
+# --------------- Miscellaneous utilities
+
+#
+# Show new revisions as the user would like to see them in the email.
+#
+show_new_revisions()
+{
+	# This shows all log entries that are not already covered by
+	# another ref - i.e. commits that are now accessible from this
+	# ref that were previously not accessible
+	# (see generate_update_branch_email for the explanation of this
+	# command)
+
+	# Revision range passed to rev-list differs for new vs. updated
+	# branches.
+	if [ "$change_type" = create ]
+	then
+		# Show all revisions exclusive to this (new) branch.
+		revspec=$newrev
+	else
+		# Branch update; show revisions not part of $oldrev.
+		revspec=$oldrev..$newrev
+	fi
+
+	git rev-parse --not --branches | grep -v $(git rev-parse $refname) |
+	git rev-list --pretty --stdin $revspec
+}
+
+
 send_mail()
 {
 	if [ -n "$envelopesender" ]; then
-- 
1.6.0.3.533.ge0502

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

* [PATCH v2 2/2] contrib/hooks/post-receive-email: Make revision display configurable
       [not found] <7v7i7kthkc.fsf@gitster.siamese.dyndns.org>
  2008-11-04  7:19 ` [PATCH v2 0/2] post-receive-email configurable rev display Pete Harlan
  2008-11-04  7:19 ` [PATCH v2 1/2] contrib/hooks/post-receive-email: Put rev display in separate function Pete Harlan
@ 2008-11-04  7:19 ` Pete Harlan
  2 siblings, 0 replies; 4+ messages in thread
From: Pete Harlan @ 2008-11-04  7:19 UTC (permalink / raw)
  To: Andy Parkins, git; +Cc: Pete Harlan

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

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

* Re: [PATCH v2 0/2] post-receive-email configurable rev display
  2008-11-04  7:19 ` [PATCH v2 0/2] post-receive-email configurable rev display Pete Harlan
@ 2008-11-04 23:55   ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2008-11-04 23:55 UTC (permalink / raw)
  To: Pete Harlan; +Cc: Andy Parkins, git

Thanks; queued.

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

end of thread, other threads:[~2008-11-04 23:58 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <7v7i7kthkc.fsf@gitster.siamese.dyndns.org>
2008-11-04  7:19 ` [PATCH v2 0/2] post-receive-email configurable rev display Pete Harlan
2008-11-04 23:55   ` Junio C Hamano
2008-11-04  7:19 ` [PATCH v2 1/2] contrib/hooks/post-receive-email: Put rev display in separate function Pete Harlan
2008-11-04  7:19 ` [PATCH v2 2/2] contrib/hooks/post-receive-email: Make revision display configurable Pete Harlan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox