Merge branch 'jc/ci-upload-artifact-and-linux32'
[git/gitster.git] / t / t3434-rebase-i18n.sh
blob26a48d6b1039a57e3111e9dafc1c8caf5422746d
1 #!/bin/sh
3 # Copyright (c) 2019 Doan Tran Cong Danh
6 test_description='rebase with changing encoding
8 Initial setup:
10 1 - 2 main
12 3 - 4 first
14 5 - 6 second
17 GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
18 export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
20 TEST_PASSES_SANITIZE_LEAK=true
21 . ./test-lib.sh
23 compare_msg () {
24 iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
25 git cat-file commit HEAD >raw &&
26 sed "1,/^$/d" raw >actual &&
27 test_cmp expect actual
30 test_expect_success setup '
31 test_commit one &&
32 git branch first &&
33 test_commit two &&
34 git switch first &&
35 test_commit three &&
36 git branch second &&
37 test_commit four &&
38 git switch second &&
39 test_commit five &&
40 test_commit six
43 test_expect_success 'rebase --rebase-merges update encoding eucJP to UTF-8' '
44 git switch -c merge-eucJP-UTF-8 first &&
45 git config i18n.commitencoding eucJP &&
46 git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
47 git config i18n.commitencoding UTF-8 &&
48 git rebase --rebase-merges main &&
49 compare_msg eucJP.txt eucJP UTF-8
52 test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
53 git switch -c merge-eucJP-ISO-2022-JP first &&
54 git config i18n.commitencoding eucJP &&
55 git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
56 git config i18n.commitencoding ISO-2022-JP &&
57 git rebase --rebase-merges main &&
58 compare_msg eucJP.txt eucJP ISO-2022-JP
61 test_rebase_continue_update_encode () {
62 old=$1
63 new=$2
64 msgfile=$3
65 test_expect_success "rebase --continue update from $old to $new" '
66 (git rebase --abort || : abort current git-rebase failure) &&
67 git switch -c conflict-$old-$new one &&
68 echo for-conflict >two.t &&
69 git add two.t &&
70 git config i18n.commitencoding $old &&
71 git commit -F "$TEST_DIRECTORY/t3434/$msgfile" &&
72 git config i18n.commitencoding $new &&
73 test_must_fail git rebase -m main &&
74 test -f .git/rebase-merge/message &&
75 git stripspace -s <.git/rebase-merge/message >two.t &&
76 git add two.t &&
77 git rebase --continue &&
78 compare_msg $msgfile $old $new &&
79 : git-commit assume invalid utf-8 is latin1 &&
80 test_cmp expect two.t
84 test_rebase_continue_update_encode ISO-8859-1 UTF-8 ISO8859-1.txt
85 test_rebase_continue_update_encode eucJP UTF-8 eucJP.txt
86 test_rebase_continue_update_encode eucJP ISO-2022-JP eucJP.txt
88 test_done