From 69cd8f63427c65c65d9cd66bb8c05ca93dc3edef Mon Sep 17 00:00:00 2001 From: Alexander Gavrilov Date: Wed, 22 Oct 2008 00:55:57 +0400 Subject: builtin-blame: Reencode commit messages according to git-log rules. Currently git-blame outputs text from the commit messages (e.g. the author name and the summary string) as-is, without even providing any information about the encoding used for the data. It makes interpreting the data in multilingual environment very difficult. This commit changes the blame implementation to recode the messages using the rules used by other commands like git-log. Namely, the target encoding can be specified through the i18n.commitEncoding or i18n.logOutputEncoding options, or directly on the command line using the --encoding parameter. Converting the encoding before output seems to be more friendly to the porcelain tools than simply providing the value of the encoding header, and does not require changing the output format. If anybody needs the old behavior, it is possible to achieve it by specifying --encoding=none. Signed-off-by: Alexander Gavrilov Signed-off-by: Junio C Hamano --- t/t8005-blame-i18n.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100755 t/t8005-blame-i18n.sh (limited to 't/t8005-blame-i18n.sh') diff --git a/t/t8005-blame-i18n.sh b/t/t8005-blame-i18n.sh new file mode 100755 index 0000000000..4470a92bb2 --- /dev/null +++ b/t/t8005-blame-i18n.sh @@ -0,0 +1,92 @@ +#!/bin/sh + +test_description='git blame encoding conversion' +. ./test-lib.sh + +. "$TEST_DIRECTORY"/t8005/utf8.txt +. "$TEST_DIRECTORY"/t8005/cp1251.txt +. "$TEST_DIRECTORY"/t8005/sjis.txt + +test_expect_success 'setup the repository' ' + # Create the file + echo "UTF-8 LINE" > file && + git add file && + git commit --author "$UTF8_NAME " -m "$UTF8_MSG" && + + echo "CP1251 LINE" >> file && + git add file && + git config i18n.commitencoding cp1251 && + git commit --author "$CP1251_NAME " -m "$CP1251_MSG" && + + echo "SJIS LINE" >> file && + git add file && + git config i18n.commitencoding shift-jis && + git commit --author "$SJIS_NAME " -m "$SJIS_MSG" +' + +cat >expected < actual && + test_cmp actual expected +' + +cat >expected < actual && + test_cmp actual expected +' + +cat >expected < actual && + test_cmp actual expected +' + +cat >expected < actual && + test_cmp actual expected +' + +test_done -- cgit v1.2.3 From 0b05dc2b7e929996afa3f325cce593585f3ec9b3 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Wed, 6 May 2009 13:31:42 -0500 Subject: t8005: use egrep when extended regular expressions are required Not all versions of grep understand backslashed extended regular expressions. Possibly only gnu grep does. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- t/t8005-blame-i18n.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 't/t8005-blame-i18n.sh') diff --git a/t/t8005-blame-i18n.sh b/t/t8005-blame-i18n.sh index 4470a92bb2..fcd5c26675 100755 --- a/t/t8005-blame-i18n.sh +++ b/t/t8005-blame-i18n.sh @@ -36,7 +36,7 @@ EOF test_expect_success \ 'blame respects i18n.commitencoding' ' git blame --incremental file | \ - grep "^\(author\|summary\) " > actual && + egrep "^(author|summary) " > actual && test_cmp actual expected ' @@ -53,7 +53,7 @@ test_expect_success \ 'blame respects i18n.logoutputencoding' ' git config i18n.logoutputencoding cp1251 && git blame --incremental file | \ - grep "^\(author\|summary\) " > actual && + egrep "^(author|summary) " > actual && test_cmp actual expected ' @@ -69,7 +69,7 @@ EOF test_expect_success \ 'blame respects --encoding=utf-8' ' git blame --incremental --encoding=utf-8 file | \ - grep "^\(author\|summary\) " > actual && + egrep "^(author|summary) " > actual && test_cmp actual expected ' @@ -85,7 +85,7 @@ EOF test_expect_success \ 'blame respects --encoding=none' ' git blame --incremental --encoding=none file | \ - grep "^\(author\|summary\) " > actual && + egrep "^(author|summary) " > actual && test_cmp actual expected ' -- cgit v1.2.3