From 28e9cf6512cae1b50a2d2003bb59da4392d99e2e Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 10 Aug 2009 18:22:18 +0200 Subject: [PATCH 1/2] Expose the has_non_ascii() function This function is useful outside of log-tree.c, too. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- commit.h | 1 + log-tree.c | 12 ------------ pretty.c | 12 ++++++++++++ 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/commit.h b/commit.h index ba9f63813eb..4886544b631 100644 --- a/commit.h +++ b/commit.h @@ -64,6 +64,7 @@ enum cmit_fmt { }; extern int non_ascii(int); +extern int has_non_ascii(const char *text); struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */ extern char *reencode_commit_message(const struct commit *commit, const char **encoding_p); diff --git a/log-tree.c b/log-tree.c index 6f73c17d74b..a3b4c0692c6 100644 --- a/log-tree.c +++ b/log-tree.c @@ -168,18 +168,6 @@ static unsigned int digits_in_number(unsigned int number) return result; } -static int has_non_ascii(const char *s) -{ - int ch; - if (!s) - return 0; - while ((ch = *s++) != '\0') { - if (non_ascii(ch)) - return 1; - } - return 0; -} - void get_patch_filename(struct commit *commit, int nr, const char *suffix, struct strbuf *buf) { diff --git a/pretty.c b/pretty.c index e5328dab5b2..3b2ecdd20e6 100644 --- a/pretty.c +++ b/pretty.c @@ -86,6 +86,18 @@ int non_ascii(int ch) return !isascii(ch) || ch == '\033'; } +int has_non_ascii(const char *s) +{ + int ch; + if (!s) + return 0; + while ((ch = *s++) != '\0') { + if (non_ascii(ch)) + return 1; + } + return 0; +} + static int is_rfc2047_special(char ch) { return (non_ascii(ch) || (ch == '=') || (ch == '?') || (ch == '_')); From 0a7f448355f38b8a626ec3c120ad7118690897fe Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 10 Aug 2009 18:22:22 +0200 Subject: [PATCH 2/2] Correctly mark cover letters' encodings if they are not pure ASCII MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If your name is, say, Üwë, you want your cover letters to appear correctly. Convince format-patch to mark it as 8-bit. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- builtin-log.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/builtin-log.c b/builtin-log.c index 0c2fa0ae2dc..1929e0a16c2 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -658,6 +658,10 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout, log_write_email_headers(rev, head, &subject_start, &extra_headers, &need_8bit_cte); + for (i = 0; !need_8bit_cte && i < nr; i++) + if (has_non_ascii(list[i]->buffer)) + need_8bit_cte = 1; + msg = body; pp_user_info(NULL, CMIT_FMT_EMAIL, &sb, committer, DATE_RFC2822, encoding);