{"thread":{"id":"28002","subject":"[PATCH] Add option hooks.emaildiff to include full diff in post-receive-email","startedAt":"2011-08-03T03:34:48Z","lastAt":"2011-08-04T03:36:08Z","messageCount":3,"participants":["Jon Jensen","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"172724","messageId":"alpine.DEB.2.02.1108022132230.3386@ybpnyubfg6.ybpnyqbznva6","threadId":"28002","inReplyTo":null,"subject":"[PATCH] Add option hooks.emaildiff to include full diff in post-receive-email","fromName":"Jon Jensen","fromEmail":"jon@endpoint.com","sentAt":"2011-08-03T03:34:48Z","receivedAt":"2011-08-03T03:34:48Z","isPatch":true,"sender":{"key":"jon@endpoint.com","avatar":"https://avatars.githubusercontent.com/u/3811?v=4"},"body":"I've always found that a very important part of receiving email\nnotification of commits is being able to read the diff inline,\neasily, where I can reply and quote the diff and make comments.\nIt's similar to the reason patches sent to the Git mailing list\nneed to be inline, not attachments.\n\nSince post-receive-email didn't have that option, this adds it as a\nboolean config variable, hooks.emaildiff.\n\nSigned-off-by: Jon Jensen <jon@endpoint.com>\n---\n contrib/hooks/post-receive-email |   13 +++++++++++--\n 1 files changed, 11 insertions(+), 2 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 21989fc..5b9b26d 100755\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -60,6 +60,9 @@\n #   email body. If not specified, there is no limit.\n #   Lines beyond the limit are suppressed and counted, and a final\n #   line is added indicating the number of suppressed lines.\n+# hooks.emaildiff\n+#   If set, then a full diff of changes is sent in addition to the default\n+#   summary output.\n #\n # Notes\n # -----\n@@ -445,8 +448,13 @@ generate_update_branch_email()\n \t# - including the undoing of previous revisions in the case of\n \t# non-fast-forward updates.\n \techo \"\"\n-\techo \"Summary of changes:\"\n-\tgit diff-tree --stat --summary --find-copies-harder $oldrev..$newrev\n+\tif [ -n \"$emaildiff\" ]; then\n+\t\techo \"Summary of changes and diff:\"\n+\t\tgit diff-tree --stat --summary --find-copies-harder -p $oldrev..$newrev\n+\telse\n+\t\techo \"Summary of changes:\"\n+\t\tgit diff-tree --stat --summary --find-copies-harder $oldrev..$newrev\n+\tfi\n }\n \n #\n@@ -723,6 +731,7 @@ envelopesender=$(git config hooks.envelopesender)\n emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')\n custom_showrev=$(git config hooks.showrev)\n maxlines=$(git config hooks.emailmaxlines)\n+emaildiff=$(git config hooks.emaildiff)\n \n # --- Main loop\n # Allow dual mode: run from the command line just like the update hook, or\n-- \n1.7.6.233.gd79bc\n"},{"id":"172790","messageId":"7vr552ba4e.fsf@alter.siamese.dyndns.org","threadId":"28002","inReplyTo":"alpine.DEB.2.02.1108022132230.3386@ybpnyubfg6.ybpnyqbznva6","subject":"Re: [PATCH] Add option hooks.emaildiff to include full diff in post-receive-email","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-08-03T18:52:49Z","receivedAt":"2011-08-03T18:52:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jon Jensen <jon@endpoint.com> writes:\n\n> -\techo \"Summary of changes:\"\n> -\tgit diff-tree --stat --summary --find-copies-harder $oldrev..$newrev\n> +\tif [ -n \"$emaildiff\" ]; then\n> +\t\techo \"Summary of changes and diff:\"\n> +\t\tgit diff-tree --stat --summary --find-copies-harder -p $oldrev..$newrev\n> +\telse\n> +\t\techo \"Summary of changes:\"\n> +\t\tgit diff-tree --stat --summary --find-copies-harder $oldrev..$newrev\n> +\tfi\n\nDepending on the project, people may want to customize other aspects of\nthe summary generation, e.g. rejecting the overhead of -f-c-h.\n\nWhy not do it like this intead?\n\n\tdiffopts=$(git config hooks.diffopts)\n\t: ${diffopts:=\"--stat --summary --find-copies-harder\"}\n        \n\techo \"Summary of changes:\"\n        git diff-tree $diffopts $oldrev..$newrev\n"},{"id":"172849","messageId":"alpine.DEB.2.02.1108032117240.12142@ybpnyubfg6.ybpnyqbznva6","threadId":"28002","inReplyTo":"7vr552ba4e.fsf@alter.siamese.dyndns.org","subject":"[PATCH] Add option hooks.diffopts to customize change summary in post-receive-email","fromName":"Jon Jensen","fromEmail":"jon@endpoint.com","sentAt":"2011-08-04T03:36:08Z","receivedAt":"2011-08-04T03:36:08Z","isPatch":true,"sender":{"key":"jon@endpoint.com","avatar":"https://avatars.githubusercontent.com/u/3811?v=4"},"body":"This makes it easy to customize the git diff-tree options, for example\nto include -p to include inline diffs.\n\nIt defaults to the current options \"--stat --summary --find-copies-harder\"\nand thus is backward-compatible.\n\nSigned-off-by: Jon Jensen <jon@endpoint.com>\nImproved-by: Junio C Hamano <gitster@pobox.com>\n---\n\nThanks for the suggestion, Junio. It makes a lot of sense.\n\nJon\n\n\n contrib/hooks/post-receive-email |    9 ++++++++-\n 1 files changed, 8 insertions(+), 1 deletions(-)\n\ndiff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email\nindex 9c678e6..cd5664d 100755\n--- a/contrib/hooks/post-receive-email\n+++ b/contrib/hooks/post-receive-email\n@@ -60,6 +60,11 @@\n #   email body. If not specified, there is no limit.\n #   Lines beyond the limit are suppressed and counted, and a final\n #   line is added indicating the number of suppressed lines.\n+# hooks.diffopts\n+#   Alternate options for the git diff-tree invocation that shows changes.\n+#   Default is \"--stat --summary --find-copies-harder\". Add -p to those\n+#   options to include a unified diff of changes in addition to the usual\n+#   summary output.\n #\n # Notes\n # -----\n@@ -447,7 +452,7 @@ generate_update_branch_email()\n \t# non-fast-forward updates.\n \techo \"\"\n \techo \"Summary of changes:\"\n-\tgit diff-tree --stat --summary --find-copies-harder $oldrev..$newrev\n+\tgit diff-tree $diffopts $oldrev..$newrev\n }\n \n #\n@@ -724,6 +729,8 @@ envelopesender=$(git config hooks.envelopesender)\n emailprefix=$(git config hooks.emailprefix || echo '[SCM] ')\n custom_showrev=$(git config hooks.showrev)\n maxlines=$(git config hooks.emailmaxlines)\n+diffopts=$(git config hooks.diffopts)\n+: ${diffopts:=\"--stat --summary --find-copies-harder\"}\n \n # --- Main loop\n # Allow dual mode: run from the command line just like the update hook, or\n-- \n1.7.6.233.gd79bc\n"}]}