1#!/bin/sh2#3# Copyright (c) 2006 Junio C Hamano4#56test_description='i18n settings and format-patch | am pipe'78. ./test-lib.sh910test_expect_success setup '11git-repo-config i18n.commitencoding UTF-8 &&1213# use UTF-8 in author and committer name to match the14# i18n.commitencoding settings15. ../t3901-utf8.txt &&1617test_tick &&18echo "$GIT_AUTHOR_NAME" >mine &&19git add mine &&20git commit -s -m "Initial commit" &&2122test_tick &&23echo Hello world >mine &&24git add mine &&25git commit -s -m "Second on main" &&2627# the first commit on the side branch is UTF-828test_tick &&29git checkout -b side master^ &&30echo Another file >yours &&31git add yours &&32git commit -s -m "Second on side" &&3334# the second one on the side branch is ISO-8859-135git-repo-config i18n.commitencoding ISO-8859-1 &&36# use author and committer name in ISO-8859-1 to match it.37. ../t3901-8859-1.txt &&38test_tick &&39echo Yet another >theirs &&40git add theirs &&41git commit -s -m "Third on side" &&4243# Back to default44git-repo-config i18n.commitencoding UTF-845'4647test_expect_success 'format-patch output (ISO-8859-1)' '48git-repo-config i18n.logoutputencoding ISO-8859-1 &&4950git format-patch --stdout master..HEAD^ >out-l1 &&51git format-patch --stdout HEAD^ >out-l2 &&52grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l1 &&53grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l1 &&54grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l2 &&55grep "^From: =?ISO-8859-1?q?=C1=E9=ED_=F3=FA?=" out-l256'5758test_expect_success 'format-patch output (UTF-8)' '59git repo-config i18n.logoutputencoding UTF-8 &&6061git format-patch --stdout master..HEAD^ >out-u1 &&62git format-patch --stdout HEAD^ >out-u2 &&63grep "^Content-Type: text/plain; charset=UTF-8" out-u1 &&64grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u1 &&65grep "^Content-Type: text/plain; charset=UTF-8" out-u2 &&66grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-u267'6869test_expect_success 'rebase (UTF-8)' '70# We want the result of rebase in UTF-871git-repo-config i18n.commitencoding UTF-8 &&7273# The test is about logoutputencoding not affecting the74# final outcome -- it is used internally to generate the75# patch and the log.7677git repo-config i18n.logoutputencoding UTF-8 &&7879# The result will be committed by GIT_COMMITTER_NAME --80# we want UTF-8 encoded name.81. ../t3901-utf8.txt &&82git checkout -b test &&83git-rebase master &&8485# Check the results.86git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&87git format-patch --stdout HEAD^ >out-r2 &&88grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&89grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r29091! git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&92! git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"93'9495test_expect_success 'rebase (ISO-8859-1)' '96git-repo-config i18n.commitencoding UTF-8 &&97git repo-config i18n.logoutputencoding ISO-8859-1 &&98. ../t3901-utf8.txt &&99100git reset --hard side &&101git-rebase master &&102103git repo-config i18n.logoutputencoding UTF-8 &&104git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&105git format-patch --stdout HEAD^ >out-r2 &&106grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&107grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&108109! git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&110! git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"111'112113test_expect_success 'rebase (ISO-8859-1)' '114# In this test we want ISO-8859-1 encoded commits as the result115git-repo-config i18n.commitencoding ISO-8859-1 &&116git repo-config i18n.logoutputencoding ISO-8859-1 &&117. ../t3901-8859-1.txt &&118119git reset --hard side &&120git-rebase master &&121122# Make sure characters are not corrupted.123git repo-config i18n.logoutputencoding UTF-8 &&124git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&125git format-patch --stdout HEAD^ >out-r2 &&126grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&127grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&128129git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&130git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"131'132133test_expect_success 'rebase (UTF-8)' '134# This is pathological -- use UTF-8 as intermediate form135# to get ISO-8859-1 results.136git-repo-config i18n.commitencoding ISO-8859-1 &&137git repo-config i18n.logoutputencoding UTF-8 &&138. ../t3901-8859-1.txt &&139140git reset --hard side &&141git-rebase master &&142143# Make sure characters are not corrupted.144git repo-config i18n.logoutputencoding UTF-8 &&145git format-patch --stdout HEAD~2..HEAD^ >out-r1 &&146git format-patch --stdout HEAD^ >out-r2 &&147grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r1 &&148grep "^From: =?UTF-8?q?=C3=81=C3=A9=C3=AD_=C3=B3=C3=BA?=" out-r2 &&149150git-cat-file commit HEAD | grep "^encoding ISO-8859-1" &&151git-cat-file commit HEAD^ | grep "^encoding ISO-8859-1"152'153154test_done