Web lists-archives.com

Re: [PATCH v5 4/5] fast-export: differentiate between explicitly utf-8 and implicitly utf-8




On Mon, May 13, 2019 at 04:17:25PM -0700, Elijah Newren wrote:
> The find_encoding() function returned the encoding used by a commit
> message, returning a default of git_commit_encoding (usually utf-8).
I think "UTF-8" is preferred over "utf-8".
Unless it is a function name like is_encoding_utf8()

> Although the current code does not differentiate between a commit which
> explicitly requested utf-8 and one where we just assume utf-8 because no
> encoding is set, it will become important when we try to preserve the
> encoding header.  Since is_encoding_utf8() returns true when passed
> NULL, we can just return NULL from find_encoding() instead of returning
> git_commit_encoding.
>
> Signed-off-by: Elijah Newren <newren@xxxxxxxxx>
> ---
>  builtin/fast-export.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/builtin/fast-export.c b/builtin/fast-export.c
> index 7734a9f5a5..66331fa401 100644
> --- a/builtin/fast-export.c
> +++ b/builtin/fast-export.c
> @@ -453,7 +453,7 @@ static const char *find_encoding(const char *begin, const char *end)
>  	bol = memmem(begin, end ? end - begin : strlen(begin),
>  		     needle, strlen(needle));
>  	if (!bol)
> -		return git_commit_encoding;
> +		return NULL;
>  	bol += strlen(needle);
>  	eol = strchrnul(bol, '\n');
>  	*eol = '\0';
> --
> 2.21.0.782.gd8be4ee826
>