{"thread":{"id":"16163","subject":"[PATCH v2 0/2] post-receive-email configurable rev display","startedAt":"2008-11-04T07:19:52Z","lastAt":"2008-11-04T23:55:45Z","messageCount":4,"participants":["Pete Harlan","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"94862","messageId":"1225783194-24640-1-git-send-email-pgit@pcharlan.com","threadId":"16163","inReplyTo":"7v7i7kthkc.fsf@gitster.siamese.dyndns.org","subject":"[PATCH v2 0/2] post-receive-email configurable rev display","fromName":"Pete Harlan","fromEmail":"pgit@pcharlan.com","sentAt":"2008-11-04T07:19:52Z","receivedAt":"2008-11-04T07:19:52Z","isPatch":true,"sender":{"key":"pgit@pcharlan.com","avatar":null},"body":"This is the second version of the user-configurable revision display\npatch.  The first version decreased the efficiency of the default\ncase, while this avoids it thanks to a suggestion by Junio.\n\nThe first version of this patch also failed to customize the display\nof revisions included in newly-created branches; this version displays\nthose revisions in the same manner as for updated branches.\n\nThe two places (new vs. updated branches) where the original code\ndisplayed revisions used similar code.  The first patch in this series\nfactors that out to a separate routine that handles both cases, in\norder to avoid duplicating the code introduced in the second patch.\n\nPete Harlan (2):\n  contrib/hooks/post-receive-email: Put rev display in separate\n    function\n  contrib/hooks/post-receive-email: Make revision display configurable\n\n contrib/hooks/post-receive-email |   57 ++++++++++++++++++++++++++++++++------\n 1 files changed, 48 insertions(+), 9 deletions(-)\n"},{"id":"94864","messageId":"1225783194-24640-2-git-send-email-pgit@pcharlan.com","threadId":"16163","inReplyTo":"1225783194-24640-1-git-send-email-pgit@pcharlan.com","subject":"[PATCH v2 1/2] contrib/hooks/post-receive-email: Put rev display in separate function","fromName":"Pete Harlan","fromEmail":"pgit@pcharlan.com","sentAt":"2008-11-04T07:19:53Z","receivedAt":"2008-11-04T07:19:53Z","isPatch":true,"sender":{"key":"pgit@pcharlan.com","avatar":null},"body":"The display of a revision in an email-appropriate format is done in\ntwo places with similar code.  In preparation for making that display\nmore complex, move it into a separate function that handles both cases.\n\nSigned-off-by: Pete Harlan <pgit@pcharlan.com>\n---\n contrib/hooks/post-receive-email |   41 +++++++++++++++++++++++++++++--------\n 1 files changed, 32 insertions(+), 9 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 4136895..2cd373d 100644\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -224,13 +224,7 @@ generate_create_branch_email()\n \techo \"\"\n \n \techo $LOGBEGIN\n-\t# This shows all log entries that are not already covered by\n-\t# another ref - i.e. commits that are now accessible from this\n-\t# ref that were previously not accessible\n-\t# (see generate_update_branch_email for the explanation of this\n-\t# command)\n-\tgit rev-parse --not --branches | grep -v $(git rev-parse $refname) |\n-\tgit rev-list --pretty --stdin $newrev\n+\tshow_new_revisions\n \techo $LOGEND\n }\n \n@@ -390,8 +384,7 @@ generate_update_branch_email()\n \n \t\techo \"\"\n \t\techo $LOGBEGIN\n-\t\tgit rev-parse --not --branches | grep -v $(git rev-parse $refname) |\n-\t\tgit rev-list --pretty --stdin $oldrev..$newrev\n+\t\tshow_new_revisions\n \n \t\t# XXX: Need a way of detecting whether git rev-list actually\n \t\t# outputted anything, so that we can issue a \"no new\n@@ -591,6 +584,36 @@ generate_delete_general_email()\n \techo $LOGEND\n }\n \n+\n+# --------------- Miscellaneous utilities\n+\n+#\n+# Show new revisions as the user would like to see them in the email.\n+#\n+show_new_revisions()\n+{\n+\t# This shows all log entries that are not already covered by\n+\t# another ref - i.e. commits that are now accessible from this\n+\t# ref that were previously not accessible\n+\t# (see generate_update_branch_email for the explanation of this\n+\t# command)\n+\n+\t# Revision range passed to rev-list differs for new vs. updated\n+\t# branches.\n+\tif [ \"$change_type\" = create ]\n+\tthen\n+\t\t# Show all revisions exclusive to this (new) branch.\n+\t\trevspec=$newrev\n+\telse\n+\t\t# Branch update; show revisions not part of $oldrev.\n+\t\trevspec=$oldrev..$newrev\n+\tfi\n+\n+\tgit rev-parse --not --branches | grep -v $(git rev-parse $refname) |\n+\tgit rev-list --pretty --stdin $revspec\n+}\n+\n+\n send_mail()\n {\n \tif [ -n \"$envelopesender\" ]; then\n-- \n1.6.0.3.533.ge0502\n"},{"id":"94863","messageId":"1225783194-24640-3-git-send-email-pgit@pcharlan.com","threadId":"16163","inReplyTo":"1225783194-24640-2-git-send-email-pgit@pcharlan.com","subject":"[PATCH v2 2/2] contrib/hooks/post-receive-email: Make revision display configurable","fromName":"Pete Harlan","fromEmail":"pgit@pcharlan.com","sentAt":"2008-11-04T07:19:54Z","receivedAt":"2008-11-04T07:19:54Z","isPatch":true,"sender":{"key":"pgit@pcharlan.com","avatar":null},"body":"Add configuration option hooks.showrev, letting the user override how\nrevisions will be shown in the commit email.\n\nSigned-off-by: Pete Harlan <pgit@pcharlan.com>\n---\n contrib/hooks/post-receive-email |   18 +++++++++++++++++-\n 1 files changed, 17 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 2cd373d..28a3c0e 100644\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -38,6 +38,12 @@\n # hooks.emailprefix\n #   All emails have their subjects prefixed with this prefix, or \"[SCM]\"\n #   if emailprefix is unset, to aid filtering\n+# hooks.showrev\n+#   The shell command used to format each revision in the email, with\n+#   \"%s\" replaced with the commit id.  Defaults to \"git rev-list -1\n+#   --pretty %s\", displaying the commit id, author, date and log\n+#   message.  To list full patches separated by a blank line, you\n+#   could set this to \"git show -C %s; echo\".\n #\n # Notes\n # -----\n@@ -610,7 +616,16 @@ show_new_revisions()\n \tfi\n \n \tgit rev-parse --not --branches | grep -v $(git rev-parse $refname) |\n-\tgit rev-list --pretty --stdin $revspec\n+\tif [ -z \"$custom_showrev\" ]\n+\tthen\n+\t\tgit rev-list --pretty --stdin $revspec\n+\telse\n+\t\tgit rev-list --stdin $revspec |\n+\t\twhile read onerev\n+\t\tdo\n+\t\t\teval $(printf \"$custom_showrev\" $onerev)\n+\t\tdone\n+\tfi\n }\n \n \n@@ -650,6 +665,7 @@ recipients=$(git config hooks.mailinglist)\n announcerecipients=$(git config hooks.announcelist)\n envelopesender=$(git config hooks.envelopesender)\n emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')\n+custom_showrev=$(git config hooks.showrev)\n \n # --- Main loop\n # Allow dual mode: run from the command line just like the update hook, or\n-- \n1.6.0.3.533.ge0502\n"},{"id":"94940","messageId":"7v8wrznj0e.fsf@gitster.siamese.dyndns.org","threadId":"16163","inReplyTo":"1225783194-24640-1-git-send-email-pgit@pcharlan.com","subject":"Re: [PATCH v2 0/2] post-receive-email configurable rev display","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-11-04T23:55:45Z","receivedAt":"2008-11-04T23:55:45Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks; queued.\n"}]}