Skip to content

Commit 3109bdb

Browse files
jrngitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1e88f7a commit 3109bdb

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

contrib/hooks/post-receive-email

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ generate_delete_branch_email()
471471
echo " was $oldrev"
472472
echo ""
473473
echo $LOGBEGIN
474-
git diff-tree -s --always --pretty=oneline $oldrev
474+
git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
475475
echo $LOGEND
476476
}
477477

@@ -571,7 +571,7 @@ generate_delete_atag_email()
571571
echo " was $oldrev"
572572
echo ""
573573
echo $LOGBEGIN
574-
git diff-tree -s --always --pretty=oneline $oldrev
574+
git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
575575
echo $LOGEND
576576
}
577577

@@ -617,7 +617,7 @@ generate_general_email()
617617
echo ""
618618
if [ "$newrev_type" = "commit" ]; then
619619
echo $LOGBEGIN
620-
git diff-tree -s --always --pretty=medium $newrev
620+
git diff-tree -s --always --encoding=UTF-8 --pretty=medium $newrev
621621
echo $LOGEND
622622
else
623623
# What can we do here? The tag marks an object that is not
@@ -636,7 +636,7 @@ generate_delete_general_email()
636636
echo " was $oldrev"
637637
echo ""
638638
echo $LOGBEGIN
639-
git diff-tree -s --always --pretty=oneline $oldrev
639+
git diff-tree -s --always --encoding=UTF-8 --pretty=oneline $oldrev
640640
echo $LOGEND
641641
}
642642

0 commit comments

Comments
 (0)