From 1e88f7a277c4cf96a425ffa66e30177b858bc965 Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 2 Aug 2013 16:22:08 -0700 Subject: hooks/post-receive-email: use plumbing instead of git log/show This way the hook doesn't have to keep being tweaked as porcelain learns new features like color and pagination. While at it, replace the "git rev-list | git shortlog" idiom with plain "git shortlog" for simplicity. Except for depending less on the value of settings like '[log] abbrevCommit', no change in output intended. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- contrib/hooks/post-receive-email | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'contrib/hooks/post-receive-email') diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email index 153115029d..72084511e7 100755 --- a/contrib/hooks/post-receive-email +++ b/contrib/hooks/post-receive-email @@ -471,7 +471,7 @@ generate_delete_branch_email() echo " was $oldrev" echo "" echo $LOGBEGIN - git show -s --pretty=oneline $oldrev + git diff-tree -s --always --pretty=oneline $oldrev echo $LOGEND } @@ -547,11 +547,11 @@ generate_atag_email() # performed on them if [ -n "$prevtag" ]; then # Show changes since the previous release - git rev-list --pretty=short "$prevtag..$newrev" | git shortlog + git shortlog "$prevtag..$newrev" else # No previous tag, show all the changes since time # began - git rev-list --pretty=short $newrev | git shortlog + git shortlog $newrev fi ;; *) @@ -571,7 +571,7 @@ generate_delete_atag_email() echo " was $oldrev" echo "" echo $LOGBEGIN - git show -s --pretty=oneline $oldrev + git diff-tree -s --always --pretty=oneline $oldrev echo $LOGEND } @@ -617,7 +617,7 @@ generate_general_email() echo "" if [ "$newrev_type" = "commit" ]; then echo $LOGBEGIN - git show --no-color --root -s --pretty=medium $newrev + git diff-tree -s --always --pretty=medium $newrev echo $LOGEND else # What can we do here? The tag marks an object that is not @@ -636,7 +636,7 @@ generate_delete_general_email() echo " was $oldrev" echo "" echo $LOGBEGIN - git show -s --pretty=oneline $oldrev + git diff-tree -s --always --pretty=oneline $oldrev echo $LOGEND } -- cgit v1.2.3 From 3109bdb0d157afbd01c412d6f3fb1c86d8b7adde Mon Sep 17 00:00:00 2001 From: Jonathan Nieder Date: Fri, 2 Aug 2013 16:23:38 -0700 Subject: hooks/post-receive-email: force log messages in UTF-8 Git commands write commit messages in UTF-8 by default, but that default can be overridden by the [i18n] commitEncoding and logOutputEncoding settings. With such a setting, the emails written by the post-receive-email hook use a mixture of encodings: 1. Log messages use the configured log output encoding, which is meant to be whatever encoding works best with local terminals (and does not have much to do with what encoding should be used for email) 2. Filenames are left as is: on Linux, usually UTF-8, and in the Mingw port (which uses Unicode filesystem APIs), always UTF-8 3. The "This is an automated email" preface uses a project description from .git/description, which is typically in UTF-8 to support gitweb. So (1) is configurable, and (2) and (3) are unconfigurable and typically UTF-8. Override the log output encoding to always use UTF-8 when writing the email to get the best chance of a comprehensible single-encoding email. Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- contrib/hooks/post-receive-email | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'contrib/hooks/post-receive-email') diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email index 72084511e7..ba93a0d845 100755 --- a/contrib/hooks/post-receive-email +++ b/contrib/hooks/post-receive-email @@ -471,7 +471,7 @@ generate_delete_branch_email() echo " was $oldrev" echo "" echo $LOGBEGIN - git diff-tree -s --always --pretty=oneline $oldrev + git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev echo $LOGEND } @@ -571,7 +571,7 @@ generate_delete_atag_email() echo " was $oldrev" echo "" echo $LOGBEGIN - git diff-tree -s --always --pretty=oneline $oldrev + git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev echo $LOGEND } @@ -617,7 +617,7 @@ generate_general_email() echo "" if [ "$newrev_type" = "commit" ]; then echo $LOGBEGIN - git diff-tree -s --always --pretty=medium $newrev + git diff-tree -s --always --encoding=UTF-8 --pretty=medium $newrev echo $LOGEND else # What can we do here? The tag marks an object that is not @@ -636,7 +636,7 @@ generate_delete_general_email() echo " was $oldrev" echo "" echo $LOGBEGIN - git diff-tree -s --always --pretty=oneline $oldrev + git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev echo $LOGEND } -- cgit v1.2.3 From 53a7296e7ebab82d23983fd5506a2bf5ee5d2d0c Mon Sep 17 00:00:00 2001 From: Gerrit Pape Date: Thu, 11 Dec 2008 20:27:21 +0000 Subject: hooks/post-receive-email: set declared encoding to utf-8 Some email clients (e.g., claws-mail) display the message body incorrectly when the charset is not defined explicitly in a Content-Type header. "git log" generates logs in UTF-8 encoding by default, so add a Content-Type header declaring that encoding to the emails the post-receive-email example hook sends. [jn: also setting the Content-Transfer-Encoding so MTAs know what kind of mangling might be needed when sending to a non 8-bit clean SMTP host] Requested-by: Alexander Gerasiov Signed-off-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- contrib/hooks/post-receive-email | 3 +++ 1 file changed, 3 insertions(+) (limited to 'contrib/hooks/post-receive-email') diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email index ba93a0d845..8ee410f843 100755 --- a/contrib/hooks/post-receive-email +++ b/contrib/hooks/post-receive-email @@ -242,6 +242,9 @@ generate_email_header() cat <<-EOF To: $recipients Subject: ${emailprefix}$projectdesc $refname_type $short_refname ${change_type}d. $describe + MIME-Version: 1.0 + Content-Type: text/plain; charset=utf-8 + Content-Transfer-Encoding: 8bit X-Git-Refname: $refname X-Git-Reftype: $refname_type X-Git-Oldrev: $oldrev -- cgit v1.2.3