t / t8005-blame-i18n.shon commit test scripts: refactor start_httpd helper (75318a3)
   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/cp1251.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 "CP1251 LINE" >> file &&
  17        git add file &&
  18        git config i18n.commitencoding cp1251 &&
  19        git commit --author "$CP1251_NAME <cp1251@localhost>" -m "$CP1251_MSG" &&
  20
  21        echo "SJIS LINE" >> file &&
  22        git add file &&
  23        git config i18n.commitencoding shift-jis &&
  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
  36test_expect_success \
  37        'blame respects i18n.commitencoding' '
  38        git blame --incremental file | \
  39                grep "^\(author\|summary\) " > actual &&
  40        test_cmp actual expected
  41'
  42
  43cat >expected <<EOF
  44author $CP1251_NAME
  45summary $CP1251_MSG
  46author $CP1251_NAME
  47summary $CP1251_MSG
  48author $CP1251_NAME
  49summary $CP1251_MSG
  50EOF
  51
  52test_expect_success \
  53        'blame respects i18n.logoutputencoding' '
  54        git config i18n.logoutputencoding cp1251 &&
  55        git blame --incremental file | \
  56                grep "^\(author\|summary\) " > actual &&
  57        test_cmp actual expected
  58'
  59
  60cat >expected <<EOF
  61author $UTF8_NAME
  62summary $UTF8_MSG
  63author $UTF8_NAME
  64summary $UTF8_MSG
  65author $UTF8_NAME
  66summary $UTF8_MSG
  67EOF
  68
  69test_expect_success \
  70        'blame respects --encoding=utf-8' '
  71        git blame --incremental --encoding=utf-8 file | \
  72                grep "^\(author\|summary\) " > actual &&
  73        test_cmp actual expected
  74'
  75
  76cat >expected <<EOF
  77author $SJIS_NAME
  78summary $SJIS_MSG
  79author $CP1251_NAME
  80summary $CP1251_MSG
  81author $UTF8_NAME
  82summary $UTF8_MSG
  83EOF
  84
  85test_expect_success \
  86        'blame respects --encoding=none' '
  87        git blame --incremental --encoding=none file | \
  88                grep "^\(author\|summary\) " > actual &&
  89        test_cmp actual expected
  90'
  91
  92test_done