fuzz: link fuzz programs with `make all` on Linux
[alt-git.git] / t / t3434-rebase-i18n.sh
blobe6fef696bbca762554d81df6f0dbdfce3aa1b8e9
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-lib.sh
22 compare_msg () {
23 iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
24 git cat-file commit HEAD >raw &&
25 sed "1,/^$/d" raw >actual &&
26 test_cmp expect actual
29 test_expect_success setup '
30 test_commit one &&
31 git branch first &&
32 test_commit two &&
33 git switch first &&
34 test_commit three &&
35 git branch second &&
36 test_commit four &&
37 git switch second &&
38 test_commit five &&
39 test_commit six
42 test_expect_success 'rebase --rebase-merges update encoding eucJP to UTF-8' '
43 git switch -c merge-eucJP-UTF-8 first &&
44 git config i18n.commitencoding eucJP &&
45 git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
46 git config i18n.commitencoding UTF-8 &&
47 git rebase --rebase-merges main &&
48 compare_msg eucJP.txt eucJP UTF-8
51 test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
52 git switch -c merge-eucJP-ISO-2022-JP first &&
53 git config i18n.commitencoding eucJP &&
54 git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
55 git config i18n.commitencoding ISO-2022-JP &&
56 git rebase --rebase-merges main &&
57 compare_msg eucJP.txt eucJP ISO-2022-JP
60 test_rebase_continue_update_encode () {
61 old=$1
62 new=$2
63 msgfile=$3
64 test_expect_success "rebase --continue update from $old to $new" '
65 (git rebase --abort || : abort current git-rebase failure) &&
66 git switch -c conflict-$old-$new one &&
67 echo for-conflict >two.t &&
68 git add two.t &&
69 git config i18n.commitencoding $old &&
70 git commit -F "$TEST_DIRECTORY/t3434/$msgfile" &&
71 git config i18n.commitencoding $new &&
72 test_must_fail git rebase -m main &&
73 test -f .git/rebase-merge/message &&
74 git stripspace <.git/rebase-merge/message >two.t &&
75 git add two.t &&
76 git rebase --continue &&
77 compare_msg $msgfile $old $new &&
78 : git-commit assume invalid utf-8 is latin1 &&
79 test_cmp expect two.t
83 test_rebase_continue_update_encode ISO-8859-1 UTF-8 ISO8859-1.txt
84 test_rebase_continue_update_encode eucJP UTF-8 eucJP.txt
85 test_rebase_continue_update_encode eucJP ISO-2022-JP eucJP.txt
87 test_done