Skip to content

Commit

Permalink
Merge branch 'ew/svn-test-and-old-i18n'
Browse files Browse the repository at this point in the history
* ew/svn-test-and-old-i18n:
  t8005: fix typo, it's ISO-8859-5, not KOI8-R
  t8005: convert CP1251 character set to ISO8859-5
  t8005: use more portable character encoding names
  t5100: use ancient encoding syntax for backwards compatibility
  t9301: use ISO8859-1 rather than ISO-8859-1
  t3901: Use ISO8859-1 instead of ISO-8859-1 for backward compatibility
  t3901: avoid negation on right hand side of '|'
  builtin-mailinfo.c: use "ISO8859-1" instead of "latin1" as fallback encoding
  builtin-mailinfo.c: compare character encodings case insensitively
  Use 'UTF-8' rather than 'utf-8' everywhere for backward compatibility
  t3900: use ancient iconv names for backward compatibility
  • Loading branch information
Junio C Hamano committed May 31, 2009
2 parents 0667621 + 1886431 commit 22cdab5
Show file tree
Hide file tree
Showing 17 changed files with 91 additions and 93 deletions.
2 changes: 1 addition & 1 deletion builtin-log.c
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
struct shortlog log;
struct strbuf sb = STRBUF_INIT;
int i;
const char *encoding = "utf-8";
const char *encoding = "UTF-8";
struct diff_options opts;
int need_8bit_cte = 0;
struct commit *commit = NULL;
Expand Down
10 changes: 4 additions & 6 deletions builtin-mailinfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,7 @@ static void handle_content_type(struct strbuf *line)
*content_top = boundary;
boundary = NULL;
}
if (slurp_attr(line->buf, "charset=", &charset))
strbuf_tolower(&charset);
slurp_attr(line->buf, "charset=", &charset);

if (boundary) {
strbuf_release(boundary);
Expand Down Expand Up @@ -481,7 +480,7 @@ static const char *guess_charset(const struct strbuf *line, const char *target_c
if (is_utf8(line->buf))
return NULL;
}
return "latin1";
return "ISO8859-1";
}

static void convert_to_utf8(struct strbuf *line, const char *charset)
Expand All @@ -494,7 +493,7 @@ static void convert_to_utf8(struct strbuf *line, const char *charset)
return;
}

if (!strcmp(metainfo_charset, charset))
if (!strcasecmp(metainfo_charset, charset))
return;
out = reencode_string(line->buf, metainfo_charset, charset);
if (!out)
Expand Down Expand Up @@ -550,7 +549,6 @@ static int decode_header_bq(struct strbuf *it)
if (cp + 3 - it->buf > it->len)
goto decode_header_bq_out;
strbuf_add(&charset_q, ep, cp - ep);
strbuf_tolower(&charset_q);

encoding = cp[1];
if (!encoding || cp[2] != '?')
Expand Down Expand Up @@ -944,7 +942,7 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
*/
git_config(git_default_config, NULL);

def_charset = (git_commit_encoding ? git_commit_encoding : "utf-8");
def_charset = (git_commit_encoding ? git_commit_encoding : "UTF-8");
metainfo_charset = def_charset;

while (1 < argc && argv[1][0] == '-') {
Expand Down
4 changes: 2 additions & 2 deletions builtin-revert.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,9 @@ static int revert_or_cherry_pick(int argc, const char **argv)

encoding = get_encoding(message);
if (!encoding)
encoding = "utf-8";
encoding = "UTF-8";
if (!git_commit_encoding)
git_commit_encoding = "utf-8";
git_commit_encoding = "UTF-8";
if ((reencoded_message = reencode_string(message,
git_commit_encoding, encoding)))
message = reencoded_message;
Expand Down
4 changes: 2 additions & 2 deletions pretty.c
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ static char *replace_encoding_header(char *buf, const char *encoding)
static char *logmsg_reencode(const struct commit *commit,
const char *output_encoding)
{
static const char *utf8 = "utf-8";
static const char *utf8 = "UTF-8";
const char *use_encoding;
char *encoding;
char *out;
Expand Down Expand Up @@ -881,7 +881,7 @@ char *reencode_commit_message(const struct commit *commit, const char **encoding
? git_log_output_encoding
: git_commit_encoding);
if (!encoding)
encoding = "utf-8";
encoding = "UTF-8";
if (encoding_p)
*encoding_p = encoding;
return logmsg_reencode(commit, encoding);
Expand Down
28 changes: 14 additions & 14 deletions t/t3900-i18n-commit.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test_expect_success 'no encoding header for base case' '
test z = "z$E"
'

for H in ISO-8859-1 EUCJP ISO-2022-JP
for H in ISO8859-1 eucJP ISO-2022-JP
do
test_expect_success "$H setup" '
git config i18n.commitencoding $H &&
Expand All @@ -44,7 +44,7 @@ do
'
done

for H in ISO-8859-1 EUCJP ISO-2022-JP
for H in ISO8859-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") &&
Expand All @@ -61,14 +61,14 @@ test_expect_success 'config to remove customization' '
else
test z = "z$Z"
fi &&
git config i18n.commitencoding utf-8
git config i18n.commitencoding UTF-8
'

test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
compare_with ISO-8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
test_expect_success 'ISO8859-1 should be shown in UTF-8 now' '
compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
'

for H in EUCJP ISO-2022-JP
for H in eucJP ISO-2022-JP
do
test_expect_success "$H should be shown in UTF-8 now" '
compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
Expand All @@ -86,7 +86,7 @@ test_expect_success 'config to add customization' '
fi
'

for H in ISO-8859-1 EUCJP ISO-2022-JP
for H in ISO8859-1 eucJP ISO-2022-JP
do
test_expect_success "$H should be shown in itself now" '
git config i18n.commitencoding '$H' &&
Expand All @@ -95,21 +95,21 @@ do
done

test_expect_success 'config to tweak customization' '
git config i18n.logoutputencoding utf-8
git config i18n.logoutputencoding UTF-8
'

test_expect_success 'ISO-8859-1 should be shown in UTF-8 now' '
compare_with ISO-8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
test_expect_success 'ISO8859-1 should be shown in UTF-8 now' '
compare_with ISO8859-1 "$TEST_DIRECTORY"/t3900/1-UTF-8.txt
'

for H in EUCJP ISO-2022-JP
for H in eucJP ISO-2022-JP
do
test_expect_success "$H should be shown in UTF-8 now" '
compare_with '$H' "$TEST_DIRECTORY"/t3900/2-UTF-8.txt
'
done

for J in EUCJP ISO-2022-JP
for J in eucJP ISO-2022-JP
do
if test "$J" = ISO-2022-JP
then
Expand All @@ -118,15 +118,15 @@ do
ICONV=
fi
git config i18n.logoutputencoding $J
for H in EUCJP ISO-2022-JP
for H in eucJP ISO-2022-JP
do
test_expect_success "$H should be shown in $J now" '
compare_with '$H' "$TEST_DIRECTORY"/t3900/'$J'.txt $ICONV
'
done
done

for H in ISO-8859-1 EUCJP ISO-2022-JP
for H in ISO8859-1 eucJP ISO-2022-JP
do
test_expect_success "No conversion with $H" '
compare_with "--encoding=none '$H'" "$TEST_DIRECTORY"/t3900/'$H'.txt
Expand Down
File renamed without changes.
File renamed without changes.
40 changes: 20 additions & 20 deletions t/t3901-i18n-patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ check_encoding () {
git cat-file commit HEAD~$j |
case "$header" in
8859)
grep "^encoding ISO-8859-1" ;;
grep "^encoding ISO8859-1" ;;
*)
! grep "^encoding ISO-8859-1" ;;
grep "^encoding ISO8859-1"; test "$?" != 0 ;;
esac || {
bad=1
break
Expand Down Expand Up @@ -55,7 +55,7 @@ test_expect_success setup '
git commit -s -m "Second on side" &&
# the second one on the side branch is ISO-8859-1
git config i18n.commitencoding ISO-8859-1 &&
git config i18n.commitencoding ISO8859-1 &&
# use author and committer name in ISO-8859-1 to match it.
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
test_tick &&
Expand All @@ -68,14 +68,14 @@ test_expect_success setup '
'

test_expect_success 'format-patch output (ISO-8859-1)' '
git config i18n.logoutputencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO8859-1 &&
git format-patch --stdout master..HEAD^ >out-l1 &&
git format-patch --stdout HEAD^ >out-l2 &&
grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l1 &&
grep "^From: =?ISO-8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 &&
grep "^Content-Type: text/plain; charset=ISO-8859-1" out-l2 &&
grep "^From: =?ISO-8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2
grep "^Content-Type: text/plain; charset=ISO8859-1" out-l1 &&
grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l1 &&
grep "^Content-Type: text/plain; charset=ISO8859-1" out-l2 &&
grep "^From: =?ISO8859-1?q?=C1=E9=ED=20=F3=FA?=" out-l2
'

test_expect_success 'format-patch output (UTF-8)' '
Expand Down Expand Up @@ -110,7 +110,7 @@ test_expect_success 'rebase (U/U)' '

test_expect_success 'rebase (U/L)' '
git config i18n.commitencoding UTF-8 &&
git config i18n.logoutputencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO8859-1 &&
. "$TEST_DIRECTORY"/t3901-utf8.txt &&
git reset --hard side &&
Expand All @@ -121,8 +121,8 @@ test_expect_success 'rebase (U/L)' '

test_expect_success 'rebase (L/L)' '
# In this test we want ISO-8859-1 encoded commits as the result
git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO-8859-1 &&
git config i18n.commitencoding ISO8859-1 &&
git config i18n.logoutputencoding ISO8859-1 &&
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
git reset --hard side &&
Expand All @@ -134,7 +134,7 @@ test_expect_success 'rebase (L/L)' '
test_expect_success 'rebase (L/U)' '
# This is pathological -- use UTF-8 as intermediate form
# to get ISO-8859-1 results.
git config i18n.commitencoding ISO-8859-1 &&
git config i18n.commitencoding ISO8859-1 &&
git config i18n.logoutputencoding UTF-8 &&
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
Expand Down Expand Up @@ -162,8 +162,8 @@ test_expect_success 'cherry-pick(U/U)' '
test_expect_success 'cherry-pick(L/L)' '
# Both the commitencoding and logoutputencoding is set to ISO-8859-1
git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO-8859-1 &&
git config i18n.commitencoding ISO8859-1 &&
git config i18n.logoutputencoding ISO8859-1 &&
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
git reset --hard master &&
Expand All @@ -178,7 +178,7 @@ test_expect_success 'cherry-pick(U/L)' '
# Commitencoding is set to UTF-8 but logoutputencoding is ISO-8859-1
git config i18n.commitencoding UTF-8 &&
git config i18n.logoutputencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO8859-1 &&
. "$TEST_DIRECTORY"/t3901-utf8.txt &&
git reset --hard master &&
Expand All @@ -193,7 +193,7 @@ test_expect_success 'cherry-pick(L/U)' '
# Again, the commitencoding is set to ISO-8859-1 but
# logoutputencoding is set to UTF-8.
git config i18n.commitencoding ISO-8859-1 &&
git config i18n.commitencoding ISO8859-1 &&
git config i18n.logoutputencoding UTF-8 &&
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
Expand All @@ -218,7 +218,7 @@ test_expect_success 'rebase --merge (U/U)' '

test_expect_success 'rebase --merge (U/L)' '
git config i18n.commitencoding UTF-8 &&
git config i18n.logoutputencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO8859-1 &&
. "$TEST_DIRECTORY"/t3901-utf8.txt &&
git reset --hard side &&
Expand All @@ -229,8 +229,8 @@ test_expect_success 'rebase --merge (U/L)' '

test_expect_success 'rebase --merge (L/L)' '
# In this test we want ISO-8859-1 encoded commits as the result
git config i18n.commitencoding ISO-8859-1 &&
git config i18n.logoutputencoding ISO-8859-1 &&
git config i18n.commitencoding ISO8859-1 &&
git config i18n.logoutputencoding ISO8859-1 &&
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
git reset --hard side &&
Expand All @@ -242,7 +242,7 @@ test_expect_success 'rebase --merge (L/L)' '
test_expect_success 'rebase --merge (L/U)' '
# This is pathological -- use UTF-8 as intermediate form
# to get ISO-8859-1 results.
git config i18n.commitencoding ISO-8859-1 &&
git config i18n.commitencoding ISO8859-1 &&
git config i18n.logoutputencoding UTF-8 &&
. "$TEST_DIRECTORY"/t3901-8859-1.txt &&
Expand Down
32 changes: 16 additions & 16 deletions t/t5100/rfc2047-samples.mbox
Original file line number Diff line number Diff line change
@@ -1,48 +1,48 @@
From nobody Mon Sep 17 00:00:00 2001
From: =?US-ASCII?Q?Keith_Moore?= <moore@cs.utk.edu>
To: =?ISO-8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>
CC: =?ISO-8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>
Subject: =?ISO-8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=
=?ISO-8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=
To: =?ISO8859-1?Q?Keld_J=F8rn_Simonsen?= <keld@dkuug.dk>
CC: =?ISO8859-1?Q?Andr=E9?= Pirard <PIRARD@vm1.ulg.ac.be>
Subject: =?ISO8859-1?B?SWYgeW91IGNhbiByZWFkIHRoaXMgeW8=?=
=?ISO8859-2?B?dSB1bmRlcnN0YW5kIHRoZSBleGFtcGxlLg==?=

From nobody Mon Sep 17 00:00:00 2001
From: =?ISO-8859-1?Q?Olle_J=E4rnefors?= <ojarnef@admin.kth.se>
From: =?ISO8859-1?Q?Olle_J=E4rnefors?= <ojarnef@admin.kth.se>
To: ietf-822@dimacs.rutgers.edu, ojarnef@admin.kth.se
Subject: Time for ISO 10646?

From nobody Mon Sep 17 00:00:00 2001
To: Dave Crocker <dcrocker@mordor.stanford.edu>
Cc: ietf-822@dimacs.rutgers.edu, paf@comsol.se
From: =?ISO-8859-1?Q?Patrik_F=E4ltstr=F6m?= <paf@nada.kth.se>
From: =?ISO8859-1?Q?Patrik_F=E4ltstr=F6m?= <paf@nada.kth.se>
Subject: Re: RFC-HDR care and feeding

From nobody Mon Sep 17 00:00:00 2001
From: Nathaniel Borenstein <nsb@thumper.bellcore.com>
(=?iso-8859-8?b?7eXs+SDv4SDp7Oj08A==?=)
(=?ISO8859-8?b?7eXs+SDv4SDp7Oj08A==?=)
To: Greg Vaudreuil <gvaudre@NRI.Reston.VA.US>, Ned Freed
<ned@innosoft.com>, Keith Moore <moore@cs.utk.edu>
Subject: Test of new header generator
MIME-Version: 1.0
Content-type: text/plain; charset=ISO-8859-1
Content-type: text/plain; charset=ISO8859-1

From nobody Mon Sep 17 00:00:00 2001
Subject: (=?ISO-8859-1?Q?a?=)
Subject: (=?ISO8859-1?Q?a?=)

From nobody Mon Sep 17 00:00:00 2001
Subject: (=?ISO-8859-1?Q?a?= b)
Subject: (=?ISO8859-1?Q?a?= b)

From nobody Mon Sep 17 00:00:00 2001
Subject: (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)
Subject: (=?ISO8859-1?Q?a?= =?ISO8859-1?Q?b?=)

From nobody Mon Sep 17 00:00:00 2001
Subject: (=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)
Subject: (=?ISO8859-1?Q?a?= =?ISO8859-1?Q?b?=)

From nobody Mon Sep 17 00:00:00 2001
Subject: (=?ISO-8859-1?Q?a?=
=?ISO-8859-1?Q?b?=)
Subject: (=?ISO8859-1?Q?a?=
=?ISO8859-1?Q?b?=)

From nobody Mon Sep 17 00:00:00 2001
Subject: (=?ISO-8859-1?Q?a_b?=)
Subject: (=?ISO8859-1?Q?a_b?=)

From nobody Mon Sep 17 00:00:00 2001
Subject: (=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)
Subject: (=?ISO8859-1?Q?a?= =?ISO8859-2?Q?_b?=)
Loading

0 comments on commit 22cdab5

Please sign in to comment.