From: Alexey Shumkin <zapped@mail.ru>
To: git@vger.kernel.org
Cc: Alexey Shumkin <zapped@mail.ru>, Junio C Hamano <gitster@pobox.com>
Subject: [PATCH] format-patch: cover letter does not respect i18n.commitencoding
Date: Tue, 20 Sep 2011 12:26:17 +0400 [thread overview]
Message-ID: <1316507177-6403-1-git-send-email-zapped@mail.ru> (raw)
When we write a cover letter it is naturally enough to suppose
that we use the same encoding as we do commits in. So make
"format-patch --cover-letter" to use i18n.commitencoding setting
in "Content-Type" header of a cover letter instead of hard-coded "UTF-8".
Especially as cover letter contains shortlog and diffstat of patches
which can contain author names and file names in i18n.commitencoding.
Signed-off-by: Alexey Shumkin <zapped@mail.ru>
---
builtin/log.c | 4 ++--
log-tree.c | 10 ++++++----
log-tree.h | 3 ++-
3 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/builtin/log.c b/builtin/log.c
index 5c2af59..6a4050c 100644
--- a/builtin/log.c
+++ b/builtin/log.c
@@ -769,7 +769,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 = get_commit_output_encoding();
struct diff_options opts;
int need_8bit_cte = 0;
struct commit *commit = NULL;
@@ -806,7 +806,7 @@ static void make_cover_letter(struct rev_info *rev, int use_stdout,
}
log_write_email_headers(rev, head, &pp.subject, &pp.after_subject,
- &need_8bit_cte);
+ &need_8bit_cte, get_commit_output_encoding());
for (i = 0; !need_8bit_cte && i < nr; i++)
if (has_non_ascii(list[i]->buffer))
diff --git a/log-tree.c b/log-tree.c
index 39913d7..403aede 100644
--- a/log-tree.c
+++ b/log-tree.c
@@ -284,7 +284,8 @@ void get_patch_filename(struct commit *commit, int nr, const char *suffix,
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
const char **subject_p,
const char **extra_headers_p,
- int *need_8bit_cte_p)
+ int *need_8bit_cte_p,
+ const char *encoding)
{
const char *subject = NULL;
const char *extra_headers = opt->extra_headers;
@@ -340,11 +341,12 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit,
"format.\n"
"--%s%s\n"
"Content-Type: text/plain; "
- "charset=UTF-8; format=fixed\n"
+ "charset=%s; format=fixed\n"
"Content-Transfer-Encoding: 8bit\n\n",
extra_headers ? extra_headers : "",
mime_boundary_leader, opt->mime_boundary,
- mime_boundary_leader, opt->mime_boundary);
+ mime_boundary_leader, opt->mime_boundary,
+ encoding);
extra_headers = subject_buffer;
get_patch_filename(opt->numbered_files ? NULL : commit, opt->nr,
@@ -433,7 +435,7 @@ void show_log(struct rev_info *opt)
if (opt->commit_format == CMIT_FMT_EMAIL) {
log_write_email_headers(opt, commit, &ctx.subject, &extra_headers,
- &ctx.need_8bit_cte);
+ &ctx.need_8bit_cte, get_commit_output_encoding());
} else if (opt->commit_format != CMIT_FMT_USERFORMAT) {
fputs(diff_get_color_opt(&opt->diffopt, DIFF_COMMIT), stdout);
if (opt->commit_format != CMIT_FMT_ONELINE)
diff --git a/log-tree.h b/log-tree.h
index 5c4cf7c..ce0acf7 100644
--- a/log-tree.h
+++ b/log-tree.h
@@ -17,7 +17,8 @@ void show_decorations(struct rev_info *opt, struct commit *commit);
void log_write_email_headers(struct rev_info *opt, struct commit *commit,
const char **subject_p,
const char **extra_headers_p,
- int *need_8bit_cte_p);
+ int *need_8bit_cte_p,
+ const char *encoding);
void load_ref_decorations(int flags);
#define FORMAT_PATCH_NAME_MAX 64
--
1.7.6.3.4.gf71f
next reply other threads:[~2011-09-20 8:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-20 8:26 Alexey Shumkin [this message]
2011-09-20 19:24 ` [PATCH] format-patch: cover letter does not respect i18n.commitencoding Junio C Hamano
2011-09-20 19:55 ` Alexey Shumkin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1316507177-6403-1-git-send-email-zapped@mail.ru \
--to=zapped@mail.ru \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).