]> git.ipfire.org Git - thirdparty/git.git/blame - t/t3434-rebase-i18n.sh
Sync with Git 2.45.1
[thirdparty/git.git] / t / t3434-rebase-i18n.sh
CommitLineData
5772b0c7
ĐTCD
1#!/bin/sh
2#
3# Copyright (c) 2019 Doan Tran Cong Danh
4#
5
6test_description='rebase with changing encoding
7
8Initial setup:
9
d1c02d93 101 - 2 main
5772b0c7
ĐTCD
11 \
12 3 - 4 first
13 \
14 5 - 6 second
15'
16
d1c02d93 17GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
334afbc7
JS
18export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
19
5772b0c7
ĐTCD
20. ./test-lib.sh
21
22compare_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
27}
28
29test_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
40'
41
42test_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 &&
d1c02d93 47 git rebase --rebase-merges main &&
5772b0c7
ĐTCD
48 compare_msg eucJP.txt eucJP UTF-8
49'
50
12029dc5 51test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
5772b0c7
ĐTCD
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 &&
d1c02d93 56 git rebase --rebase-merges main &&
5772b0c7
ĐTCD
57 compare_msg eucJP.txt eucJP ISO-2022-JP
58'
59
52f52e5a
ĐTCD
60test_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 &&
d1c02d93 72 test_must_fail git rebase -m main &&
52f52e5a 73 test -f .git/rebase-merge/message &&
a6c2654f 74 git stripspace -s <.git/rebase-merge/message >two.t &&
52f52e5a
ĐTCD
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
80 '
81}
82
83test_rebase_continue_update_encode ISO-8859-1 UTF-8 ISO8859-1.txt
84test_rebase_continue_update_encode eucJP UTF-8 eucJP.txt
85test_rebase_continue_update_encode eucJP ISO-2022-JP eucJP.txt
86
5772b0c7 87test_done