From b45974a655e0e41441e5db64c091000171435096 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 23 Dec 2006 23:36:55 -0800 Subject: Move encoding conversion routine out of mailinfo to utf8.c This moves the body of convert_to_utf8() routine used in mailinfo to the utf8.c i18n library. Signed-off-by: Junio C Hamano diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index e647229..507b93f 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -4,6 +4,7 @@ */ #include "cache.h" #include "builtin.h" +#include "utf8.h" static FILE *cmitmsg, *patchfile, *fin, *fout; @@ -510,40 +511,18 @@ static int decode_b_segment(char *in, char *ot, char *ep) static void convert_to_utf8(char *line, char *charset) { -#ifndef NO_ICONV - char *in, *out; - size_t insize, outsize, nrc; - char outbuf[4096]; /* cheat */ static char latin_one[] = "latin1"; char *input_charset = *charset ? charset : latin_one; - iconv_t conv = iconv_open(metainfo_charset, input_charset); - - if (conv == (iconv_t) -1) { - static int warned_latin1_once = 0; - if (input_charset != latin_one) { - fprintf(stderr, "cannot convert from %s to %s\n", - input_charset, metainfo_charset); - *charset = 0; - } - else if (!warned_latin1_once) { - warned_latin1_once = 1; - fprintf(stderr, "tried to convert from %s to %s, " - "but your iconv does not work with it.\n", - input_charset, metainfo_charset); - } + char *out = reencode_string(line, metainfo_charset, input_charset); + + if (!out) { + fprintf(stderr, "cannot convert from %s to %s\n", + input_charset, metainfo_charset); + *charset = 0; return; } - in = line; - insize = strlen(in); - out = outbuf; - outsize = sizeof(outbuf); - nrc = iconv(conv, &in, &insize, &out, &outsize); - iconv_close(conv); - if (nrc == (size_t) -1) - return; - *out = 0; - strcpy(line, outbuf); -#endif + strcpy(line, out); + free(out); } static int decode_header_bq(char *it) diff --git a/utf8.c b/utf8.c index 8fa6257..1eedd8b 100644 --- a/utf8.c +++ b/utf8.c @@ -276,3 +276,57 @@ void print_wrapped_text(const char *text, int indent, int indent2, int width) } } } + +/* + * Given a buffer and its encoding, return it re-encoded + * with iconv. If the conversion fails, returns NULL. + */ +#ifndef NO_ICONV +char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding) +{ + iconv_t conv; + size_t insz, outsz, outalloc; + char *out, *outpos, *cp; + + if (!in_encoding) + return NULL; + conv = iconv_open(out_encoding, in_encoding); + if (conv == (iconv_t) -1) + return NULL; + insz = strlen(in); + outsz = insz; + outalloc = outsz + 1; /* for terminating NUL */ + out = xmalloc(outalloc); + outpos = out; + cp = (char *)in; + + while (1) { + size_t cnt = iconv(conv, &cp, &insz, &outpos, &outsz); + + if (cnt == -1) { + size_t sofar; + if (errno != E2BIG) { + free(out); + iconv_close(conv); + return NULL; + } + /* insz has remaining number of bytes. + * since we started outsz the same as insz, + * it is likely that insz is not enough for + * converting the rest. + */ + sofar = outpos - out; + outalloc = sofar + insz * 2 + 32; + out = xrealloc(out, outalloc); + outpos = out + sofar; + outsz = outalloc - sofar - 1; + } + else { + *outpos = '\0'; + break; + } + } + iconv_close(conv); + return out; +} +#endif diff --git a/utf8.h b/utf8.h index a0d7f59..cae2a8e 100644 --- a/utf8.h +++ b/utf8.h @@ -5,4 +5,10 @@ int utf8_width(const char **start); int is_utf8(const char *text); void print_wrapped_text(const char *text, int indent, int indent2, int len); +#ifndef NO_ICONV +char *reencode_string(const char *in, const char *out_encoding, const char *in_encoding); +#else +#define reencode_string(a,b,c) NULL +#endif + #endif -- cgit v0.10.2-6-g49f6 From 4b2bced55948422198dad92dcbf4b5b98913f1e7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 23 Dec 2006 23:53:02 -0800 Subject: i18n.logToUTF8: convert commit log message to UTF-8 When i18n.commitencoding is set to a non UTF-8 encoding, commit-tree records the encoding in an extra header after author/committer headers in the commit object. An earlier version used trailer but Johannes points out that there is little risk breaking existing Porcelains with a new header. Signed-off-by: Junio C Hamano diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index f641787..33c29f7 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -92,6 +92,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) char comment[1000]; char *buffer; unsigned int size; + int encoding_is_utf8; setup_ident(); git_config(git_default_config); @@ -117,6 +118,8 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) parents++; } + encoding_is_utf8 = !strcmp(git_commit_encoding, "utf-8"); + init_buffer(&buffer, &size); add_buffer(&buffer, &size, "tree %s\n", sha1_to_hex(tree_sha1)); @@ -130,7 +133,11 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) /* Person/date information */ add_buffer(&buffer, &size, "author %s\n", git_author_info(1)); - add_buffer(&buffer, &size, "committer %s\n\n", git_committer_info(1)); + add_buffer(&buffer, &size, "committer %s\n", git_committer_info(1)); + if (!encoding_is_utf8) + add_buffer(&buffer, &size, + "encoding %s\n", git_commit_encoding); + add_buffer(&buffer, &size, "\n"); /* And add the comment */ while (fgets(comment, sizeof(comment), stdin) != NULL) @@ -138,7 +145,7 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) /* And check the encoding */ buffer[size] = '\0'; - if (!strcmp(git_commit_encoding, "utf-8") && !is_utf8(buffer)) + if (encoding_is_utf8 && !is_utf8(buffer)) fprintf(stderr, commit_utf8_warn); if (!write_sha1_file(buffer, size, commit_type, commit_sha1)) { -- cgit v0.10.2-6-g49f6 From 52883fbd767f8a79a6f98a08907d0a9f6ba1ece1 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 25 Dec 2006 11:48:35 -0800 Subject: Teach log family --encoding Updated commit objects record the encoding used in their encoding header. This updates the log family to reencode it into the encoding specified in i18n.commitencoding (or the default, which is "utf-8") upon output. To force a specific encoding that is different, log family takes command line flag --encoding=; giving --encoding=none entirely disables the reencoding and lets you view log messges in their original encoding. Signed-off-by: Junio C Hamano diff --git a/builtin-log.c b/builtin-log.c index 8df3c13..b7e47cb 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -20,6 +20,8 @@ void add_head(struct rev_info *revs); static void cmd_log_init(int argc, const char **argv, const char *prefix, struct rev_info *rev) { + int i; + rev->abbrev = DEFAULT_ABBREV; rev->commit_format = CMIT_FMT_DEFAULT; rev->verbose_header = 1; @@ -27,8 +29,21 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, argc = setup_revisions(argc, argv, rev, "HEAD"); if (rev->diffopt.pickaxe || rev->diffopt.filter) rev->always_show_header = 0; - if (argc > 1) - die("unrecognized argument: %s", argv[1]); + for (i = 1; i < argc; i++) { + const char *arg = argv[i]; + if (!strncmp(arg, "--encoding=", 11)) { + arg += 11; + if (MAX_ENCODING_LENGTH <= strlen(arg)) + die(" Value of output encoding '%s' too long", + arg); + if (strcmp(arg, "none")) + strcpy(git_commit_encoding, arg); + else + git_commit_encoding[0] = 0; + } + else + die("unrecognized argument: %s", arg); + } } static int cmd_log_walk(struct rev_info *rev) diff --git a/commit.c b/commit.c index 289ef65..df4bc07 100644 --- a/commit.c +++ b/commit.c @@ -1,6 +1,7 @@ #include "cache.h" #include "tag.h" #include "commit.h" +#include "utf8.h" int save_commit_buffer = 1; @@ -563,10 +564,53 @@ static int add_merge_info(enum cmit_fmt fmt, char *buf, const struct commit *com return offset; } -unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit, - unsigned long len, char *buf, unsigned long space, +static char *get_header(const struct commit *commit, const char *key) +{ + int key_len = strlen(key); + const char *line = commit->buffer; + + for (;;) { + const char *eol = strchr(line, '\n'), *next; + + if (line == eol) + return NULL; + if (!eol) { + eol = line + strlen(line); + next = NULL; + } else + next = eol + 1; + if (!strncmp(line, key, key_len) && line[key_len] == ' ') { + int len = eol - line - key_len; + char *ret = xmalloc(len); + memcpy(ret, line + key_len + 1, len - 1); + ret[len - 1] = '\0'; + return ret; + } + line = next; + } +} + +static char *logmsg_reencode(const struct commit *commit) +{ + char *encoding = get_header(commit, "encoding"); + char *out; + + if (!encoding || !strcmp(encoding, git_commit_encoding)) + return NULL; + out = reencode_string(commit->buffer, git_commit_encoding, encoding); + free(encoding); + if (!out) + return NULL; + return out; +} + +unsigned long pretty_print_commit(enum cmit_fmt fmt, + const struct commit *commit, + unsigned long len, + char *buf, unsigned long space, int abbrev, const char *subject, - const char *after_subject, int relative_date) + const char *after_subject, + int relative_date) { int hdr = 1, body = 0; unsigned long offset = 0; @@ -574,6 +618,15 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit int parents_shown = 0; const char *msg = commit->buffer; int plain_non_ascii = 0; + char *reencoded = NULL; + + if (*git_commit_encoding) { + reencoded = logmsg_reencode(commit); + if (reencoded) { + msg = reencoded; + len = strlen(msg); + } + } if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL) indent = 0; @@ -721,6 +774,8 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit if (fmt == CMIT_FMT_EMAIL && !body) buf[offset++] = '\n'; buf[offset] = '\0'; + + free(reencoded); return offset; } diff --git a/revision.h b/revision.h index ec991e5..8f7907d 100644 --- a/revision.h +++ b/revision.h @@ -72,6 +72,7 @@ struct rev_info { const char *ref_message_id; const char *add_signoff; const char *extra_headers; + const char *log_reencode; /* Filter by commit log message */ struct grep_opt *grep_filter; -- cgit v0.10.2-6-g49f6 From d2c11a38c476bdfa3dd2387a0d933b8c00e4dfe3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 27 Dec 2006 16:41:33 -0800 Subject: UTF-8: introduce i18n.logoutputencoding. It is plausible for somebody to want to view the commit log in a different encoding from i18n.commitencoding -- the project's policy may be UTF-8 and the user may be using a commit message hook to run iconv to conform to that policy (and either not have i18n.commitencoding to default to UTF-8 or have it explicitly set to UTF-8). Even then, Latin-1 may be more convenient for the usual pager and the terminal the user uses. The new variable i18n.logoutputencoding is used in preference to i18n.commitencoding to decide what encoding to recode the log output in when git-log and friends formats the commit log message. Signed-off-by: Junio C Hamano diff --git a/Documentation/config.txt b/Documentation/config.txt index 22482d6..ffef3ab 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -248,6 +248,10 @@ i18n.commitEncoding:: browser (and possibly at other places in the future or in other porcelains). See e.g. gitlink:git-mailinfo[1]. Defaults to 'utf-8'. +i18n.logOutputEncoding:: + Character encoding the commit messages are converted to when + running `git-log` and friends. + log.showroot:: If true, the initial commit will be shown as a big creation event. This is equivalent to a diff against an empty tree. diff --git a/builtin-commit-tree.c b/builtin-commit-tree.c index 33c29f7..146aaff 100644 --- a/builtin-commit-tree.c +++ b/builtin-commit-tree.c @@ -118,7 +118,9 @@ int cmd_commit_tree(int argc, const char **argv, const char *prefix) parents++; } - encoding_is_utf8 = !strcmp(git_commit_encoding, "utf-8"); + /* Not having i18n.commitencoding is the same as having utf-8 */ + encoding_is_utf8 = (!git_commit_encoding || + !strcmp(git_commit_encoding, "utf-8")); init_buffer(&buffer, &size); add_buffer(&buffer, &size, "tree %s\n", sha1_to_hex(tree_sha1)); diff --git a/builtin-log.c b/builtin-log.c index b7e47cb..a59b4ac 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -33,13 +33,10 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, const char *arg = argv[i]; if (!strncmp(arg, "--encoding=", 11)) { arg += 11; - if (MAX_ENCODING_LENGTH <= strlen(arg)) - die(" Value of output encoding '%s' too long", - arg); if (strcmp(arg, "none")) - strcpy(git_commit_encoding, arg); + git_log_output_encoding = strdup(arg); else - git_commit_encoding[0] = 0; + git_log_output_encoding = ""; } else die("unrecognized argument: %s", arg); diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 507b93f..a67f3eb 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -806,7 +806,8 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix) if (!strcmp(argv[1], "-k")) keep_subject = 1; else if (!strcmp(argv[1], "-u")) - metainfo_charset = git_commit_encoding; + metainfo_charset = (git_commit_encoding + ? git_commit_encoding : "utf-8"); else if (!strncmp(argv[1], "--encoding=", 11)) metainfo_charset = argv[1] + 11; else diff --git a/cache.h b/cache.h index 4943056..29dd290 100644 --- a/cache.h +++ b/cache.h @@ -416,8 +416,8 @@ extern int check_repository_format_version(const char *var, const char *value); extern char git_default_email[MAX_GITNAME]; extern char git_default_name[MAX_GITNAME]; -#define MAX_ENCODING_LENGTH 64 -extern char git_commit_encoding[MAX_ENCODING_LENGTH]; +extern char *git_commit_encoding; +extern char *git_log_output_encoding; extern int copy_fd(int ifd, int ofd); extern void write_or_die(int fd, const void *buf, size_t count); diff --git a/commit.c b/commit.c index df4bc07..6f2839a 100644 --- a/commit.c +++ b/commit.c @@ -592,12 +592,20 @@ static char *get_header(const struct commit *commit, const char *key) static char *logmsg_reencode(const struct commit *commit) { - char *encoding = get_header(commit, "encoding"); + char *encoding; char *out; + char *output_encoding = (git_log_output_encoding + ? git_log_output_encoding + : git_commit_encoding); - if (!encoding || !strcmp(encoding, git_commit_encoding)) + if (!output_encoding) return NULL; - out = reencode_string(commit->buffer, git_commit_encoding, encoding); + encoding = get_header(commit, "encoding"); + if (!encoding || !strcmp(encoding, output_encoding)) { + free(encoding); + return NULL; + } + out = reencode_string(commit->buffer, output_encoding, encoding); free(encoding); if (!out) return NULL; @@ -618,15 +626,10 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, int parents_shown = 0; const char *msg = commit->buffer; int plain_non_ascii = 0; - char *reencoded = NULL; + char *reencoded = logmsg_reencode(commit); - if (*git_commit_encoding) { - reencoded = logmsg_reencode(commit); - if (reencoded) { - msg = reencoded; - len = strlen(msg); - } - } + if (reencoded) + msg = reencoded; if (fmt == CMIT_FMT_ONELINE || fmt == CMIT_FMT_EMAIL) indent = 0; @@ -643,7 +646,7 @@ unsigned long pretty_print_commit(enum cmit_fmt fmt, for (in_body = i = 0; (ch = msg[i]) && i < len; i++) { if (!in_body) { /* author could be non 7-bit ASCII but - * the log may so; skip over the + * the log may be so; skip over the * header part first. */ if (ch == '\n' && diff --git a/config.c b/config.c index 1662a46..fcccf7e 100644 --- a/config.c +++ b/config.c @@ -309,10 +309,16 @@ int git_default_config(const char *var, const char *value) } if (!strcmp(var, "i18n.commitencoding")) { - strlcpy(git_commit_encoding, value, sizeof(git_commit_encoding)); + git_commit_encoding = strdup(value); return 0; } + if (!strcmp(var, "i18n.logoutputencoding")) { + git_log_output_encoding = strdup(value); + return 0; + } + + if (!strcmp(var, "pager.color") || !strcmp(var, "color.pager")) { pager_use_color = git_config_bool(var,value); return 0; diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 234cd09..7c7520e 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -711,6 +711,7 @@ _git_repo_config () core.compression core.legacyHeaders i18n.commitEncoding + i18n.logOutputEncoding diff.color color.diff diff.renameLimit diff --git a/environment.c b/environment.c index f8c7dbc..a1502c4 100644 --- a/environment.c +++ b/environment.c @@ -18,7 +18,8 @@ int prefer_symlink_refs; int log_all_ref_updates; int warn_ambiguous_refs = 1; int repository_format_version; -char git_commit_encoding[MAX_ENCODING_LENGTH] = "utf-8"; +char *git_commit_encoding; +char *git_log_output_encoding; int shared_repository = PERM_UMASK; const char *apply_default_whitespace; int zlib_compression_level = Z_DEFAULT_COMPRESSION; diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh new file mode 100755 index 0000000..3606ed2 --- /dev/null +++ b/t/t3900-i18n-commit.sh @@ -0,0 +1,104 @@ +#!/bin/sh +# +# Copyright (c) 2006 Junio C Hamano +# + +test_description='commit and log output encodings' + +. ./test-lib.sh + +compare_with () { + git-show -s "$1" | sed -e '1,/^$/d' -e 's/^ //' -e '$d' >current && + diff -u current "$2" +} + +test_expect_success setup ' + : >F && + git-add F && + T=$(git-write-tree) && + C=$(git-commit-tree $T <../t3900/1-UTF-8.txt) && + git-update-ref HEAD $C && + git-tag C0 +' + +test_expect_success 'no encoding header for base case' ' + E=$(git-cat-file commit C0 | sed -ne "s/^encoding //p") && + test z = "z$E" +' + +for H in ISO-8859-1 EUCJP ISO2022JP +do + test_expect_success "$H setup" ' + git-repo-config i18n.commitencoding $H && + git-checkout -b $H C0 && + echo $H >F && + git-commit -a -F ../t3900/$H.txt + ' +done + +for H in ISO-8859-1 EUCJP ISO2022JP +do + test_expect_success "check encoding header for $H" ' + E=$(git-cat-file commit '$H' | sed -ne "s/^encoding //p") && + test "z$E" = "z'$H'" + ' +done + +test_expect_success 'repo-config to remove customization' ' + git-repo-config --unset-all i18n.commitencoding && + if Z=$(git-repo-config --get-all i18n.commitencoding) + then + echo Oops, should have failed. + false + else + test z = "z$Z" + fi && + git-repo-config i18n.commitencoding utf-8 +' + +test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' + compare_with ISO-8859-1 ../t3900/1-UTF-8.txt +' + +for H in EUCJP ISO2022JP +do + test_expect_success "$H should be shown in UTF-8 now" ' + compare_with '$H' ../t3900/2-UTF-8.txt + ' +done + +test_expect_success 'repo-config to add customization' ' + git-repo-config --unset-all i18n.commitencoding && + if Z=$(git-repo-config --get-all i18n.commitencoding) + then + echo Oops, should have failed. + false + else + test z = "z$Z" + fi +' + +for H in ISO-8859-1 EUCJP ISO2022JP +do + test_expect_success "$H should be shown in itself now" ' + git-repo-config i18n.commitencoding '$H' && + compare_with '$H' ../t3900/'$H'.txt + ' +done + +test_expect_success 'repo-config to tweak customization' ' + git-repo-config i18n.logoutputencoding utf-8 +' + +test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' + compare_with ISO-8859-1 ../t3900/1-UTF-8.txt +' + +for H in EUCJP ISO2022JP +do + test_expect_success "$H should be shown in UTF-8 now" ' + compare_with '$H' ../t3900/2-UTF-8.txt + ' +done + +test_done diff --git a/t/t3900/1-UTF-8.txt b/t/t3900/1-UTF-8.txt new file mode 100644 index 0000000..ee31e19 --- /dev/null +++ b/t/t3900/1-UTF-8.txt @@ -0,0 +1,3 @@ +ÄËÑÏÖ + +Ábçdèfg diff --git a/t/t3900/2-UTF-8.txt b/t/t3900/2-UTF-8.txt new file mode 100644 index 0000000..63f4f8f --- /dev/null +++ b/t/t3900/2-UTF-8.txt @@ -0,0 +1,4 @@ +はれひほふ + +しているのが、いるので。 +濱浜ほれぷりぽれまびぐりろへ。 diff --git a/t/t3900/EUCJP.txt b/t/t3900/EUCJP.txt new file mode 100644 index 0000000..546f2aa --- /dev/null +++ b/t/t3900/EUCJP.txt @@ -0,0 +1,4 @@ +ϤҤۤ + +ƤΤΤǡ +ͤۤפݤޤӤء diff --git a/t/t3900/ISO-8859-1.txt b/t/t3900/ISO-8859-1.txt new file mode 100644 index 0000000..7cbef0e --- /dev/null +++ b/t/t3900/ISO-8859-1.txt @@ -0,0 +1,3 @@ + + +bdfg diff --git a/t/t3900/ISO2022JP.txt b/t/t3900/ISO2022JP.txt new file mode 100644 index 0000000..74b5330 --- /dev/null +++ b/t/t3900/ISO2022JP.txt @@ -0,0 +1,4 @@ +$B$O$l$R$[$U(B + +$B$7$F$$$k$N$,!"$$$k$N$G!#(B +$B_@IM$[$l$W$j$]$l$^$S$0$j$m$X!#(B -- cgit v0.10.2-6-g49f6 From 46e35a6cb9914ebb839249ecf2154c48b044c5cd Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 27 Dec 2006 17:38:02 -0800 Subject: Rename t3900 test vector file It appears ISO-2022-JP is more widely accepted than ISO2022JP, so rename it that way. We probably would need to have a way to skip this test altogether in locale-challenged environments. Signed-off-by: Junio C Hamano diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index 3606ed2..879b697 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -26,7 +26,7 @@ test_expect_success 'no encoding header for base case' ' test z = "z$E" ' -for H in ISO-8859-1 EUCJP ISO2022JP +for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "$H setup" ' git-repo-config i18n.commitencoding $H && @@ -36,7 +36,7 @@ do ' done -for H in ISO-8859-1 EUCJP ISO2022JP +for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "check encoding header for $H" ' E=$(git-cat-file commit '$H' | sed -ne "s/^encoding //p") && @@ -60,7 +60,7 @@ test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' compare_with ISO-8859-1 ../t3900/1-UTF-8.txt ' -for H in EUCJP ISO2022JP +for H in EUCJP ISO-2022-JP do test_expect_success "$H should be shown in UTF-8 now" ' compare_with '$H' ../t3900/2-UTF-8.txt @@ -78,7 +78,7 @@ test_expect_success 'repo-config to add customization' ' fi ' -for H in ISO-8859-1 EUCJP ISO2022JP +for H in ISO-8859-1 EUCJP ISO-2022-JP do test_expect_success "$H should be shown in itself now" ' git-repo-config i18n.commitencoding '$H' && @@ -94,7 +94,7 @@ test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' ' compare_with ISO-8859-1 ../t3900/1-UTF-8.txt ' -for H in EUCJP ISO2022JP +for H in EUCJP ISO-2022-JP do test_expect_success "$H should be shown in UTF-8 now" ' compare_with '$H' ../t3900/2-UTF-8.txt diff --git a/t/t3900/ISO-2022-JP.txt b/t/t3900/ISO-2022-JP.txt new file mode 100644 index 0000000..74b5330 --- /dev/null +++ b/t/t3900/ISO-2022-JP.txt @@ -0,0 +1,4 @@ +$B$O$l$R$[$U(B + +$B$7$F$$$k$N$,!"$$$k$N$G!#(B +$B_@IM$[$l$W$j$]$l$^$S$0$j$m$X!#(B diff --git a/t/t3900/ISO2022JP.txt b/t/t3900/ISO2022JP.txt deleted file mode 100644 index 74b5330..0000000 --- a/t/t3900/ISO2022JP.txt +++ /dev/null @@ -1,4 +0,0 @@ -$B$O$l$R$[$U(B - -$B$7$F$$$k$N$,!"$$$k$N$G!#(B -$B_@IM$[$l$W$j$]$l$^$S$0$j$m$X!#(B -- cgit v0.10.2-6-g49f6 From 7255ff0446217ad723dad6088504a18f6afb15db Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Thu, 28 Dec 2006 17:36:35 -0800 Subject: t3900: test conversion to non UTF-8 as well Signed-off-by: Junio C Hamano diff --git a/t/t3900-i18n-commit.sh b/t/t3900-i18n-commit.sh index 879b697..46fd47c 100755 --- a/t/t3900-i18n-commit.sh +++ b/t/t3900-i18n-commit.sh @@ -101,4 +101,15 @@ do ' done +for J in EUCJP ISO-2022-JP +do + git-repo-config i18n.logoutputencoding $J + for H in EUCJP ISO-2022-JP + do + test_expect_success "$H should be shown in $J now" ' + compare_with '$H' ../t3900/'$J'.txt + ' + done +done + test_done -- cgit v0.10.2-6-g49f6