]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: reencode commit message for am/rebase --show-current-patch
authorDoan Tran Cong Danh <congdanhqx@gmail.com>
Mon, 11 Nov 2019 06:03:41 +0000 (13:03 +0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 11 Nov 2019 09:03:35 +0000 (18:03 +0900)
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>
sequencer.c
t/t3434-rebase-i18n.sh
t/t3434/ISO8859-1.txt [new file with mode: 0644]

index d735d09f9888220f35b38f49fb8857827c6df14b..4d12ad3cc6e2c33df86112accacdc8fee1d814d9 100644 (file)
@@ -2972,7 +2972,8 @@ static int make_patch(struct repository *r,
 
        strbuf_addf(&buf, "%s/message", get_dir(opts));
        if (!file_exists(buf.buf)) {
-               const char *commit_buffer = get_commit_buffer(commit, NULL);
+               const char *encoding = get_commit_output_encoding();
+               const char *commit_buffer = logmsg_reencode(commit, NULL, encoding);
                find_commit_subject(commit_buffer, &subject);
                res |= write_message(subject, strlen(subject), buf.buf, 1);
                unuse_commit_buffer(commit, commit_buffer);
index c6c16373eb8e97a59a7324673bbcfdc92592f67f..4b5b128cd608c8683ccdb289ecb7ef68a49fda0a 100755 (executable)
@@ -54,4 +54,31 @@ test_expect_failure 'rebase --rebase-merges update encoding eucJP to ISO-2022-JP
        compare_msg eucJP.txt eucJP ISO-2022-JP
 '
 
+test_rebase_continue_update_encode () {
+       old=$1
+       new=$2
+       msgfile=$3
+       test_expect_success "rebase --continue update from $old to $new" '
+               (git rebase --abort || : abort current git-rebase failure) &&
+               git switch -c conflict-$old-$new one &&
+               echo for-conflict >two.t &&
+               git add two.t &&
+               git config i18n.commitencoding $old &&
+               git commit -F "$TEST_DIRECTORY/t3434/$msgfile" &&
+               git config i18n.commitencoding $new &&
+               test_must_fail git rebase -m master &&
+               test -f .git/rebase-merge/message &&
+               git stripspace <.git/rebase-merge/message >two.t &&
+               git add two.t &&
+               git rebase --continue &&
+               compare_msg $msgfile $old $new &&
+               : git-commit assume invalid utf-8 is latin1 &&
+               test_cmp expect two.t
+       '
+}
+
+test_rebase_continue_update_encode ISO-8859-1 UTF-8 ISO8859-1.txt
+test_rebase_continue_update_encode eucJP UTF-8 eucJP.txt
+test_rebase_continue_update_encode eucJP ISO-2022-JP eucJP.txt
+
 test_done
diff --git a/t/t3434/ISO8859-1.txt b/t/t3434/ISO8859-1.txt
new file mode 100644 (file)
index 0000000..7cbef0e
--- /dev/null
@@ -0,0 +1,3 @@
+ÄËÑÏÖ
+
+Ábçdèfg