Skip to content

Commit 52f52e5

Browse files
sgngitster
authored andcommitted
sequencer: reencode commit message for am/rebase --show-current-patch
The message file will be used as commit message for the git-{am,rebase} --continue. Signed-off-by: Doan Tran Cong Danh <congdanhqx@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 5772b0c commit 52f52e5

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

sequencer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2972,7 +2972,8 @@ static int make_patch(struct repository *r,
29722972

29732973
strbuf_addf(&buf, "%s/message", get_dir(opts));
29742974
if (!file_exists(buf.buf)) {
2975-
const char *commit_buffer = get_commit_buffer(commit, NULL);
2975+
const char *encoding = get_commit_output_encoding();
2976+
const char *commit_buffer = logmsg_reencode(commit, NULL, encoding);
29762977
find_commit_subject(commit_buffer, &subject);
29772978
res |= write_message(subject, strlen(subject), buf.buf, 1);
29782979
unuse_commit_buffer(commit, commit_buffer);

t/t3434-rebase-i18n.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,31 @@ test_expect_failure 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP
5454
compare_msg eucJP.txt eucJP ISO-2022-JP
5555
'
5656

57+
test_rebase_continue_update_encode () {
58+
old=$1
59+
new=$2
60+
msgfile=$3
61+
test_expect_success "rebase --continue update from $old to $new" '
62+
(git rebase --abort || : abort current git-rebase failure) &&
63+
git switch -c conflict-$old-$new one &&
64+
echo for-conflict >two.t &&
65+
git add two.t &&
66+
git config i18n.commitencoding $old &&
67+
git commit -F "$TEST_DIRECTORY/t3434/$msgfile" &&
68+
git config i18n.commitencoding $new &&
69+
test_must_fail git rebase -m master &&
70+
test -f .git/rebase-merge/message &&
71+
git stripspace <.git/rebase-merge/message >two.t &&
72+
git add two.t &&
73+
git rebase --continue &&
74+
compare_msg $msgfile $old $new &&
75+
: git-commit assume invalid utf-8 is latin1 &&
76+
test_cmp expect two.t
77+
'
78+
}
79+
80+
test_rebase_continue_update_encode ISO-8859-1 UTF-8 ISO8859-1.txt
81+
test_rebase_continue_update_encode eucJP UTF-8 eucJP.txt
82+
test_rebase_continue_update_encode eucJP ISO-2022-JP eucJP.txt
83+
5784
test_done

t/t3434/ISO8859-1.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
�����
2+
3+
�b�d�fg

0 commit comments

Comments
 (0)