t / t8005-blame-i18n.shon commit Merge branch 'pw/add-p-single' (60f8b89)
   1#!/bin/sh
   2
   3test_description='git blame encoding conversion'
   4. ./test-lib.sh
   5
   6. "$TEST_DIRECTORY"/t8005/utf8.txt
   7. "$TEST_DIRECTORY"/t8005/euc-japan.txt
   8. "$TEST_DIRECTORY"/t8005/sjis.txt
   9
  10test_expect_success 'setup the repository' '
  11        # Create the file
  12        echo "UTF-8 LINE" > file &&
  13        git add file &&
  14        git commit --author "$UTF8_NAME <utf8@localhost>" -m "$UTF8_MSG" &&
  15
  16        echo "EUC-JAPAN LINE" >> file &&
  17        git add file &&
  18        git config i18n.commitencoding eucJP &&
  19        git commit --author "$EUC_JAPAN_NAME <euc-japan@localhost>" -m "$EUC_JAPAN_MSG" &&
  20
  21        echo "SJIS LINE" >> file &&
  22        git add file &&
  23        git config i18n.commitencoding SJIS &&
  24        git commit --author "$SJIS_NAME <sjis@localhost>" -m "$SJIS_MSG"
  25'
  26
  27cat >expected <<EOF
  28author $SJIS_NAME
  29summary $SJIS_MSG
  30author $SJIS_NAME
  31summary $SJIS_MSG
  32author $SJIS_NAME
  33summary $SJIS_MSG
  34EOF
  35
  36filter_author_summary () {
  37        sed -n -e '/^author /p' -e '/^summary /p' "$@"
  38}
  39
  40test_expect_success !MINGW \
  41        'blame respects i18n.commitencoding' '
  42        git blame --incremental file >output &&
  43        filter_author_summary output >actual &&
  44        test_cmp expected actual
  45'
  46
  47cat >expected <<EOF
  48author $EUC_JAPAN_NAME
  49summary $EUC_JAPAN_MSG
  50author $EUC_JAPAN_NAME
  51summary $EUC_JAPAN_MSG
  52author $EUC_JAPAN_NAME
  53summary $EUC_JAPAN_MSG
  54EOF
  55
  56test_expect_success !MINGW \
  57        'blame respects i18n.logoutputencoding' '
  58        git config i18n.logoutputencoding eucJP &&
  59        git blame --incremental file >output &&
  60        filter_author_summary output >actual &&
  61        test_cmp expected actual
  62'
  63
  64cat >expected <<EOF
  65author $UTF8_NAME
  66summary $UTF8_MSG
  67author $UTF8_NAME
  68summary $UTF8_MSG
  69author $UTF8_NAME
  70summary $UTF8_MSG
  71EOF
  72
  73test_expect_success !MINGW \
  74        'blame respects --encoding=UTF-8' '
  75        git blame --incremental --encoding=UTF-8 file >output &&
  76        filter_author_summary output >actual &&
  77        test_cmp expected actual
  78'
  79
  80cat >expected <<EOF
  81author $SJIS_NAME
  82summary $SJIS_MSG
  83author $EUC_JAPAN_NAME
  84summary $EUC_JAPAN_MSG
  85author $UTF8_NAME
  86summary $UTF8_MSG
  87EOF
  88
  89test_expect_success !MINGW \
  90        'blame respects --encoding=none' '
  91        git blame --incremental --encoding=none file >output &&
  92        filter_author_summary output >actual &&
  93        test_cmp expected actual
  94'
  95
  96test_done