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

Re: [PATCH v3 1/2] add --recode-patch option to git-mailinfo

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 16, 2010, 19:27 UTC
Message-ID
<7vhbl2eq1g.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1276664983-5693-1-git-send-email-r0bertz@gentoo.org>
Zhang Le <r0bertz@gentoo.org> writes:
Show 10 quoted lines
> diff --git a/Documentation/git-mailinfo.txt b/Documentation/git-mailinfo.txt
> index 3ea5aad..24d5bd7 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.  Unless --recode-patch is used.
Somehow this doesn't rhyme well.  Perhaps
    Note that the patch is used as-with without charset conversion; use
    `--recode-patch` for that.
would be better?
Show 7 quoted lines
> @@ -54,6 +54,10 @@ conversion, even with this flag.
>  -n::
>  	Disable all charset re-coding of the metadata.
>  
> +--recode-patch::
> +	Similar to -u.  But what is re-coded is the patch instead of the
> +	metainfo.  The default is off.
Ditto.
	Convert the patch from the e-mail to UTF-8 (or the value of the
	configuration variable `i18n.commitencoding`, if it is set).
By the way, what happens when somebody runs the following command?
	git mailinfo -n --recode-patch
Is it desirable?  If not, what _should_ happen instead?
Show 38 quoted lines
> diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
> index 4a9729b..bb87b32 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 int recode_patch;
>  static struct strbuf line = STRBUF_INIT;
>  static struct strbuf name = STRBUF_INIT;
>  static struct strbuf email = STRBUF_INIT;
> @@ -828,8 +829,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 (recode_patch)
> +		convert_to_utf8(line, charset.buf);
>  	fwrite(line->buf, 1, line->len, patchfile);
>  	patch_lines++;
>  }
> @@ -1021,7 +1024,7 @@ static int git_mailinfo_config(const char *var, const char *value, void *unused)
>  }
>  
>  static const char mailinfo_usage[] =
> -	"git mailinfo [-k|-b] [-u | --encoding=<encoding> | -n] [--scissors | --no-scissors] msg patch < mail >info";
> +	"git mailinfo [-k|-b] [-u | --encoding=<encoding> | -n] [--recode-patch] [--scissors | --no-scissors] msg patch < mail >info";
>  
>  int cmd_mailinfo(int argc, const char **argv, const char *prefix)
>  {
> @@ -1034,6 +1037,7 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix)
>  
>  	def_charset = (git_commit_encoding ? git_commit_encoding : "UTF-8");
>  	metainfo_charset = def_charset;
> +	recode_patch = 0;
Do you need this assignment?
Previous: Zhang LeNext: Zhang Le
Message 3 of 4 in “add --recode-patch option to git-mailinfo”
  1. 1/2 add --recode-patch option to git-mailinfoZhang Le, Jun 16, 2010
  2. 2/2 add --recode-patch option to git-amZhang Le, Jun 16, 2010
  3. Junio C HamanoJun 16, 2010
  4. Zhang LeJun 17, 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.