git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] i18n.repositoryencoding: a new variable specifying the encoding of blobs in the repository

From
ZHANG, Le <r0bertz@gentoo.org>
Date
Apr 16, 2011, 20:50 UTC
Message-ID
<1302987004-28134-1-git-send-email-r0bertz@gentoo.org>

When not set it defaults to 'verbatim', nothing will be done. When set, the encoding of the blobs in repository will be converted to it. The original encoding is get from mail header.

Signed-off-by: ZHANG, Le <r0bertz@gentoo.org>
---
 Documentation/git-mailinfo.txt |    2 +-
 builtin/mailinfo.c             |    6 +++++-
 cache.h                        |    2 ++
 config.c                       |    3 +++
 environment.c                  |    6 ++++++
 5 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt
index ed45662..cbdd9bb 100644
--- a/Documentation/git-mailinfo.txt
+++ b/Documentation/git-mailinfo.txt
@@ -45,7 +45,7 @@ OPTIONS
 	them.  This used to be optional but now it is the default.
 +
 Note that the patch is always used as-is without charset
-conversion, even with this flag.
+conversion, even with this flag; use 'i18n.repositoryencoding' for that.
 
 --encoding=<encoding>::
 	Similar to -u.  But when re-coding, the charset specified here is
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index 0f42ff1..51d950b 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -12,6 +12,7 @@ static FILE *cmitmsg, *patchfile, *fin, *fout;
 static int keep_subject;
 static int keep_non_patch_brackets_in_subject;
 static const char *metainfo_charset;
+static const char *repository_charset;
 static struct strbuf line = STRBUF_INIT;
 static struct strbuf name = STRBUF_INIT;
 static struct strbuf email = STRBUF_INIT;
@@ -824,8 +825,10 @@ static int handle_commit_msg(struct strbuf *line)
 	return 0;
 }
 
-static void handle_patch(const struct strbuf *line)
+static void handle_patch(struct strbuf *line)
 {
+	if (strcasecmp(repository_charset, "verbatim"))
+		convert_to(line, repository_charset, charset.buf);
 	fwrite(line->buf, 1, line->len, patchfile);
 	patch_lines++;
 }
@@ -1030,6 +1033,7 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
 
 	def_charset = get_commit_output_encoding();
 	metainfo_charset = def_charset;
+	repository_charset = get_repository_encoding();
 
 	while (1 < argc && argv[1][0] == '-') {
 		if (!strcmp(argv[1], "-k"))
diff --git a/cache.h b/cache.h
index 2674f4c..ebc3a92 100644
--- a/cache.h
+++ b/cache.h
@@ -1029,6 +1029,7 @@ extern int git_config_system(void);
 extern int config_error_nonbool(const char *);
 extern const char *get_log_output_encoding(void);
 extern const char *get_commit_output_encoding(void);
+extern const char *get_repository_encoding(void);
 
 extern const char *config_exclusive_filename;
 
@@ -1042,6 +1043,7 @@ extern int user_ident_explicitly_given;
 extern int user_ident_sufficiently_given(void);
 
 extern const char *git_commit_encoding;
+extern const char *git_repository_encoding;
 extern const char *git_log_output_encoding;
 extern const char *git_mailmap_file;
 
diff --git a/config.c b/config.c
index 0abcada..35cc09a 100644
--- a/config.c
+++ b/config.c
@@ -691,6 +691,9 @@ static int git_default_i18n_config(const char *var, const char *value)
 	if (!strcmp(var, "i18n.commitencoding"))
 		return git_config_string(&git_commit_encoding, var, value);
 
+	if (!strcmp(var, "i18n.repositoryencoding"))
+		return git_config_string(&git_repository_encoding, var, value);
+
 	if (!strcmp(var, "i18n.logoutputencoding"))
 		return git_config_string(&git_log_output_encoding, var, value);
 
diff --git a/environment.c b/environment.c
index f4549d3..135fdfc 100644
--- a/environment.c
+++ b/environment.c
@@ -24,6 +24,7 @@ int log_all_ref_updates = -1; /* unspecified */
 int warn_ambiguous_refs = 1;
 int repository_format_version;
 const char *git_commit_encoding;
+const char *git_repository_encoding;
 const char *git_log_output_encoding;
 int shared_repository = PERM_UMASK;
 const char *apply_default_whitespace;
@@ -232,3 +233,8 @@ const char *get_commit_output_encoding(void)
 {
 	return git_commit_encoding ? git_commit_encoding : "UTF-8";
 }
+
+const char *get_repository_encoding(void)
+{
+    return git_repository_encoding ? git_repository_encoding : "verbatim";
+}
-- 
1.7.5.rc2.5.gb2ee76.dirty
Next: Junio C Hamano
Message 1 of 2 in “i18n.repositoryencoding: a new variable specifying the encoding of blobs in the repository”
  1. 2/2 i18n.repositoryencoding: a new variable specifying the encoding of blobs in the repositoryZHANG, Le, Apr 16, 2011
  2. Junio C HamanoApr 19, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.