Re: [PATCH] Reencode committer info to utf-8 before formatting mail header
Junio C Hamano <junkio@cox.net> writes:
> Side note. The previous patch does not help if your commit were
> made in non UTF-8 with not too recent git; the code assumes that
> commit messages without the new "encoding" headers are in UTF-8.
This was exactly the problem I was trying to solve.
Show 29 quoted lines
> We might want to help transitioning people by doing something
> like this on top of the previous patch. Then when dealing with
> an ancient commit (sorry, I am not saying commits older than 3
> weeks are ancient -- but it will be 6 months from now ;-), you
> can override that default by setting an environment variable.
>
> ---
> diff --git a/commit.c b/commit.c
> index 9b2b842..a1b5705 100644
> --- a/commit.c
> +++ b/commit.c
> @@ -692,8 +692,12 @@ static char *logmsg_reencode(const struct commit *commit,
> if (!*output_encoding)
> return NULL;
> encoding = get_header(commit, "encoding");
> - if (!encoding)
> - encoding = utf8;
> + if (!encoding) {
> + if (getenv("GIT_OLD_COMMIT_ENCODING"))
> + encoding = strdup(getenv("GIT_OLD_COMMIT_ENCODING"));
> + else
> + encoding = utf8;
> + }
> if (!strcmp(encoding, output_encoding))
> out = strdup(commit->buffer);
> else
>
>
>--
David Kågedal