blob: e6fef696bbca762554d81df6f0dbdfce3aa1b8e9 [file] [log] [blame]
Doan Tran Cong Danh5772b0c2019-11-11 13:03:40 +07001#!/bin/sh
2#
3# Copyright (c) 2019 Doan Tran Cong Danh
4#
5
6test_description='rebase with changing encoding
7
8Initial setup:
9
Johannes Schindelind1c02d92020-11-18 23:44:25 +0000101 - 2 main
Doan Tran Cong Danh5772b0c2019-11-11 13:03:40 +070011 \
12 3 - 4 first
13 \
14 5 - 6 second
15'
16
Johannes Schindelind1c02d92020-11-18 23:44:25 +000017GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
Johannes Schindelin334afbc2020-11-18 23:44:19 +000018export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
19
Doan Tran Cong Danh5772b0c2019-11-11 13:03:40 +070020. ./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 &&
Johannes Schindelind1c02d92020-11-18 23:44:25 +000047 git rebase --rebase-merges main &&
Doan Tran Cong Danh5772b0c2019-11-11 13:03:40 +070048 compare_msg eucJP.txt eucJP UTF-8
49'
50
Elijah Newren12029dc2019-12-13 21:03:45 +000051test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
Doan Tran Cong Danh5772b0c2019-11-11 13:03:40 +070052 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 &&
Johannes Schindelind1c02d92020-11-18 23:44:25 +000056 git rebase --rebase-merges main &&
Doan Tran Cong Danh5772b0c2019-11-11 13:03:40 +070057 compare_msg eucJP.txt eucJP ISO-2022-JP
58'
59
Doan Tran Cong Danh52f52e52019-11-11 13:03:41 +070060test_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 &&
Johannes Schindelind1c02d92020-11-18 23:44:25 +000072 test_must_fail git rebase -m main &&
Doan Tran Cong Danh52f52e52019-11-11 13:03:41 +070073 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
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
Doan Tran Cong Danh5772b0c2019-11-11 13:03:40 +070087test_done