Merge branch 'ds/doc-clone-filter'
[git.git] / t / t3434-rebase-i18n.sh
blobc7c835cde9b23b26675b5d5b1729e8be6a2b6d26
1 #!/bin/sh
3 # Copyright (c) 2019 Doan Tran Cong Danh
6 test_description='rebase with changing encoding
8 Initial setup:
10 1 - 2 master
12 3 - 4 first
14 5 - 6 second
17 . ./test-lib.sh
19 compare_msg () {
20 iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
21 git cat-file commit HEAD >raw &&
22 sed "1,/^$/d" raw >actual &&
23 test_cmp expect actual
26 test_expect_success setup '
27 test_commit one &&
28 git branch first &&
29 test_commit two &&
30 git switch first &&
31 test_commit three &&
32 git branch second &&
33 test_commit four &&
34 git switch second &&
35 test_commit five &&
36 test_commit six
39 test_expect_success 'rebase --rebase-merges update encoding eucJP to UTF-8' '
40 git switch -c merge-eucJP-UTF-8 first &&
41 git config i18n.commitencoding eucJP &&
42 git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
43 git config i18n.commitencoding UTF-8 &&
44 git rebase --rebase-merges master &&
45 compare_msg eucJP.txt eucJP UTF-8
48 test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
49 git switch -c merge-eucJP-ISO-2022-JP first &&
50 git config i18n.commitencoding eucJP &&
51 git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
52 git config i18n.commitencoding ISO-2022-JP &&
53 git rebase --rebase-merges master &&
54 compare_msg eucJP.txt eucJP ISO-2022-JP
57 test_rebase_continue_update_encode () {
58 old=$1
59 new=$2
60 msgfile=$3
61 test_expect_success "rebase --continue update from $old to $new" '
62 (git rebase --abort || : abort current git-rebase failure) &&
63 git switch -c conflict-$old-$new one &&
64 echo for-conflict >two.t &&
65 git add two.t &&
66 git config i18n.commitencoding $old &&
67 git commit -F "$TEST_DIRECTORY/t3434/$msgfile" &&
68 git config i18n.commitencoding $new &&
69 test_must_fail git rebase -m master &&
70 test -f .git/rebase-merge/message &&
71 git stripspace <.git/rebase-merge/message >two.t &&
72 git add two.t &&
73 git rebase --continue &&
74 compare_msg $msgfile $old $new &&
75 : git-commit assume invalid utf-8 is latin1 &&
76 test_cmp expect two.t
80 test_rebase_continue_update_encode ISO-8859-1 UTF-8 ISO8859-1.txt
81 test_rebase_continue_update_encode eucJP UTF-8 eucJP.txt
82 test_rebase_continue_update_encode eucJP ISO-2022-JP eucJP.txt
84 test_done