Skip to content

Commit 5772b0c

Browse files
sgngitster
authored andcommitted
sequencer: reencode old merge-commit message
During rebasing, old merge's message (encoded in old encoding) will be used as message for new merge commit (created by rebase). In case of the value of i18n.commitencoding has been changed after the old merge time. We will receive an unusable message for this new merge. Correct it. This change also notice a breakage with git-rebase label system. Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent b375744 commit 5772b0c

File tree

3 files changed

+63
-1
lines changed

3 files changed

+63
-1
lines changed

sequencer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3374,7 +3374,8 @@ static int do_merge(struct repository *r,
33743374
}
33753375

33763376
if (commit) {
3377-
const char *message = get_commit_buffer(commit, NULL);
3377+
const char *encoding = get_commit_output_encoding();
3378+
const char *message = logmsg_reencode(commit, NULL, encoding);
33783379
const char *body;
33793380
int len;
33803381

t/t3434-rebase-i18n.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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+
10+
1 - 2 master
11+
\
12+
3 - 4 first
13+
\
14+
5 - 6 second
15+
'
16+
17+
. ./test-lib.sh
18+
19+
compare_msg () {
20+
iconv -f "$2" -t "$3" "$TEST_DIRECTORY/t3434/$1" >expect &&
21+
git cat-file commit HEAD >raw &&
22+
sed "1,/^$/d" raw >actual &&
23+
test_cmp expect actual
24+
}
25+
26+
test_expect_success setup '
27+
test_commit one &&
28+
git branch first &&
29+
test_commit two &&
30+
git switch first &&
31+
test_commit three &&
32+
git branch second &&
33+
test_commit four &&
34+
git switch second &&
35+
test_commit five &&
36+
test_commit six
37+
'
38+
39+
test_expect_success 'rebase --rebase-merges update encoding eucJP to UTF-8' '
40+
git switch -c merge-eucJP-UTF-8 first &&
41+
git config i18n.commitencoding eucJP &&
42+
git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
43+
git config i18n.commitencoding UTF-8 &&
44+
git rebase --rebase-merges master &&
45+
compare_msg eucJP.txt eucJP UTF-8
46+
'
47+
48+
test_expect_failure 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP' '
49+
git switch -c merge-eucJP-ISO-2022-JP first &&
50+
git config i18n.commitencoding eucJP &&
51+
git merge -F "$TEST_DIRECTORY/t3434/eucJP.txt" second &&
52+
git config i18n.commitencoding ISO-2022-JP &&
53+
git rebase --rebase-merges master &&
54+
compare_msg eucJP.txt eucJP ISO-2022-JP
55+
'
56+
57+
test_done

t/t3434/eucJP.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
�Ϥ�Ҥۤ�
2+
3+
���Ƥ���Τ�������Τǡ�
4+
���ͤۤ�פ�ݤ�ޤӤ�����ء�

0 commit comments

Comments
 (0)