Doan Tran Cong Danh | 5772b0c | 2019-11-11 13:03:40 +0700 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Copyright (c) 2019 Doan Tran Cong Danh |
| 4 | # |
| 5 | |
| 6 | test_description='rebase with changing encoding |
| 7 | |
| 8 | Initial setup: |
| 9 | |
Johannes Schindelin | d1c02d9 | 2020-11-18 23:44:25 +0000 | [diff] [blame] | 10 | 1 - 2 main |
Doan Tran Cong Danh | 5772b0c | 2019-11-11 13:03:40 +0700 | [diff] [blame] | 11 | \ |
| 12 | 3 - 4 first |
| 13 | \ |
| 14 | 5 - 6 second |
| 15 | ' |
| 16 | |
Johannes Schindelin | d1c02d9 | 2020-11-18 23:44:25 +0000 | [diff] [blame] | 17 | GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main |
Johannes Schindelin | 334afbc | 2020-11-18 23:44:19 +0000 | [diff] [blame] | 18 | export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME |
| 19 | |
Doan Tran Cong Danh | 5772b0c | 2019-11-11 13:03:40 +0700 | [diff] [blame] | 20 | . ./test-lib.sh |
| 21 | |
| 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 |
| 27 | } |
| 28 | |
| 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 |
| 40 | ' |
| 41 | |
| 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 && |
Johannes Schindelin | d1c02d9 | 2020-11-18 23:44:25 +0000 | [diff] [blame] | 47 | git rebase --rebase-merges main && |
Doan Tran Cong Danh | 5772b0c | 2019-11-11 13:03:40 +0700 | [diff] [blame] | 48 | compare_msg eucJP.txt eucJP UTF-8 |
| 49 | ' |
| 50 | |
Elijah Newren | 12029dc | 2019-12-13 21:03:45 +0000 | [diff] [blame] | 51 | test_expect_success 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' ' |
Doan Tran Cong Danh | 5772b0c | 2019-11-11 13:03:40 +0700 | [diff] [blame] | 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 && |
Johannes Schindelin | d1c02d9 | 2020-11-18 23:44:25 +0000 | [diff] [blame] | 56 | git rebase --rebase-merges main && |
Doan Tran Cong Danh | 5772b0c | 2019-11-11 13:03:40 +0700 | [diff] [blame] | 57 | compare_msg eucJP.txt eucJP ISO-2022-JP |
| 58 | ' |
| 59 | |
Doan Tran Cong Danh | 52f52e5 | 2019-11-11 13:03:41 +0700 | [diff] [blame] | 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 && |
Johannes Schindelin | d1c02d9 | 2020-11-18 23:44:25 +0000 | [diff] [blame] | 72 | test_must_fail git rebase -m main && |
Doan Tran Cong Danh | 52f52e5 | 2019-11-11 13:03:41 +0700 | [diff] [blame] | 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 |
| 80 | ' |
| 81 | } |
| 82 | |
| 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 |
| 86 | |
Doan Tran Cong Danh | 5772b0c | 2019-11-11 13:03:40 +0700 | [diff] [blame] | 87 | test_done |