1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
|
From d41b94fca5748b0e51f7d505641c396328714813 Mon Sep 17 00:00:00 2001
From: Jonathan Nieder <jrnieder@gmail.com>
Date: Fri, 7 Oct 2011 04:06:02 -0500
Subject: [PATCH 02/12] post-receive-email: defend against non-utf8
i18n.logoutputencoding setting
The post-receive-email example hook includes a description of the
repository taken from $GIT_DIR/description in the emails it sends.
Gitweb also uses that file and assumes it to be UTF-8. When
[i18n] logoutputencoding is not UTF-8, the result is a message
composed with multiple encodings.
This patch teaches post-receive-email to use plumbing where possible
and to explicitly declare what encoding it expects output to use so
the output uses UTF-8 consistently.
Making the email charset configurable is left as an exercise for the
interested reader.
Reported-by: Alexey Shumkin <zapped@mail.ru>
Helped-by: Johannes Sixt <j6t@kdbg.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
contrib/hooks/post-receive-email | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/contrib/hooks/post-receive-email b/contrib/hooks/post-receive-email
index dc184d0..b59e03c 100755
--- a/contrib/hooks/post-receive-email
+++ b/contrib/hooks/post-receive-email
@@ -464,7 +464,7 @@ generate_delete_branch_email()
echo " was $oldrev"
echo ""
echo $LOGBEGIN
- git show -s --pretty=oneline $oldrev
+ git diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev
echo $LOGEND
}
@@ -540,11 +540,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 --encoding=UTF-8 "$prevtag..$newrev"
else
# No previous tag, show all the changes since time
# began
- git rev-list --pretty=short $newrev | git shortlog
+ git shortlog --encoding=UTF-8 "$newrev"
fi
;;
*)
@@ -564,7 +564,7 @@ generate_delete_atag_email()
echo " was $oldrev"
echo ""
echo $LOGBEGIN
- git show -s --pretty=oneline $oldrev
+ git diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev
echo $LOGEND
}
@@ -610,7 +610,7 @@ generate_general_email()
echo ""
if [ "$newrev_type" = "commit" ]; then
echo $LOGBEGIN
- git show --no-color --root -s --pretty=medium $newrev
+ git diff-tree --encoding=UTF-8 --root -s --pretty=oneline $newrev
echo $LOGEND
else
# What can we do here? The tag marks an object that is not
@@ -629,7 +629,7 @@ generate_delete_general_email()
echo " was $oldrev"
echo ""
echo $LOGBEGIN
- git show -s --pretty=oneline $oldrev
+ git diff-tree --encoding=UTF-8 -s --pretty=oneline $oldrev
echo $LOGEND
}
--
1.7.10
|