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

[PATCH v4 1/4] mailinfo.c: convert_to_utf8(): added a target_charset parameter

From
ZHANG, Le <r0bertz@gentoo.org>
Date
Nov 28, 2010, 19:10 UTC
Message-ID
<1290971417-4474-2-git-send-email-r0bertz@gentoo.org>
In-Reply-To
<1290971417-4474-1-git-send-email-r0bertz@gentoo.org>
This is required for my recode-patch patch which needs a seperate patch_charset variable.
Signed-off-by: ZHANG, Le <r0bertz@gentoo.org>
---
 builtin/mailinfo.c |   16 ++++++++--------
 1 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index 2320d98..1406d9f 100644
--- a/builtin/mailinfo.c
+++ b/builtin/mailinfo.c
@@ -492,22 +492,22 @@ static const char *guess_charset(const struct strbuf *line, const char *target_c
 	return "ISO8859-1";
 }
 
-static void convert_to_utf8(struct strbuf *line, const char *charset)
+static void convert_to_utf8(struct strbuf *line, const char *charset, const char *target_charset)
 {
 	char *out;
 
 	if (!charset || !*charset) {
-		charset = guess_charset(line, metainfo_charset);
+		charset = guess_charset(line, target_charset);
 		if (!charset)
 			return;
 	}
 
-	if (!strcasecmp(metainfo_charset, charset))
+	if (!strcasecmp(target_charset, charset))
 		return;
-	out = reencode_string(line->buf, metainfo_charset, charset);
+	out = reencode_string(line->buf, target_charset, charset);
 	if (!out)
 		die("cannot convert from %s to %s",
-		    charset, metainfo_charset);
+		    charset, target_charset);
 	strbuf_attach(line, out, strlen(out), strlen(out));
 }
 
@@ -577,7 +577,7 @@ static int decode_header_bq(struct strbuf *it)
 			break;
 		}
 		if (metainfo_charset)
-			convert_to_utf8(dec, charset_q.buf);
+			convert_to_utf8(dec, charset_q.buf, metainfo_charset);
 
 		strbuf_addbuf(&outbuf, dec);
 		strbuf_release(dec);
@@ -602,7 +602,7 @@ static void decode_header(struct strbuf *it)
 	 * This can be binary guck but there is no charset specified.
 	 */
 	if (metainfo_charset)
-		convert_to_utf8(it, "");
+		convert_to_utf8(it, "", metainfo_charset);
 }
 
 static void decode_transfer_encoding(struct strbuf *line)
@@ -796,7 +796,7 @@ static int handle_commit_msg(struct strbuf *line)
 
 	/* normalize the log message to UTF-8. */
 	if (metainfo_charset)
-		convert_to_utf8(line, charset.buf);
+		convert_to_utf8(line, charset.buf, metainfo_charset);
 
 	if (use_scissors && is_scissors_line(line)) {
 		int i;
-- 
1.7.3.2.344.gb3680.dirty
Previous: ZHANG, LeNext: Junio C Hamano
Message 2 of 9 in “add --recode-patch parameter to mailinfo and am”
  1. 0/4 add --recode-patch parameter to mailinfo and amZHANG, Le, Nov 28, 2010
  2. 1/4 mailinfo.c: convert_to_utf8(): added a target_charset parameterZHANG, Le, Nov 28, 2010
  3. Junio C HamanoNov 29, 2010
  4. ZHANG, LeApr 16, 2011
  5. 2/4 i18n.patchencoding: introduce a new config variableZHANG, Le, Nov 28, 2010
  6. Junio C HamanoNov 29, 2010
  7. 3/4 git mailinfo: added a --recode-patch parameterZHANG, Le, Nov 28, 2010
  8. Junio C HamanoNov 29, 2010
  9. 4/4 git am: added a --recode-patch parameterZHANG, Le, Nov 28, 2010

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.