[PATCH] format-patch: cover letter does not respect i18n.commitencoding

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]