Tests redirect to err file when grepping stderr
[stgit.git] / t / t1305-repair-encodings.sh
blobea1fc8402e7da3d882f18c052b2a46fa2f55d852
1 #!/bin/sh
3 test_description='Test "stg repair" with non-utf-8 commit data encodings'
5 . ./test-lib.sh
7 test_expect_success 'Create git commit with ISO8859-1 message and author' '
8 echo foo > foo.txt &&
9 git add foo.txt &&
10 git commit -a -m foo &&
11 echo "0" >> foo.txt &&
12 test_config i18n.commitencoding ISO8859-1 &&
14 . "$TEST_DIRECTORY"/t1305/author-8859-1.txt &&
15 git commit -a -F "$TEST_DIRECTORY"/t1305/message-8859-1.txt
16 ) &&
17 git cat-file -p HEAD | grep -e "^encoding ISO8859-1"
20 test_expect_success 'Initialize the StGit repository' '
21 stg init
24 test_expect_success 'No-op repair with non-utf-8 encoded message in history' '
25 stg repair
28 test_expect_success 'Uncommit patch' '
29 stg uncommit -n 1
32 test_expect_success 'Check patch name is utf-8' '
33 test "$(stg series --applied --noprefix)" = "äëñïö"
36 test_expect_success 'Check show is utf-8' '
37 stg show | grep -e "Author: Áéí óú <author@example.com>"
40 test_expect_success 'Check underlying commit is ISO8859-1' '
41 git cat-file -p HEAD > "$HOME"/commit-data.txt &&
42 cat "$HOME"/commit-data.txt |
43 grep -e "^encoding ISO8859-1" &&
44 cat "$HOME"/commit-data.txt |
45 grep -e "^author" |
46 cut -d" " -f 2-4 > "$HOME"/auth-8859-1.txt &&
47 cat "$HOME"/auth-8859-1.txt |
48 iconv -f ISO8859-1 -t UTF-8 > "$HOME"/auth-utf8.txt &&
49 test "Áéí óú <author@example.com>" = "$(cat "$HOME"/auth-utf8.txt)"
52 test_expect_success 'Encoding after edit' '
53 stg edit --sign 2> "$HOME"/warnings.txt &&
54 test_must_be_empty "$HOME"/warnings.txt &&
55 git cat-file -p HEAD | grep -e "ÄËÑÏÖ" &&
56 git cat-file -p HEAD | grep -e "Ábçdèfg" &&
57 git cat-file -p HEAD | grep -e "Signed-off-by: C Ó Mitter <committer@example.com>"
60 test_done