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

Re: [PATCH] pretty: user format ignores i18n.logOutputEncoding setting

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 25, 2011, 19:45 UTC
Message-ID
<7vwrf6qh49.fsf@alter.siamese.dyndns.org>
In-Reply-To
<1311589875-12569-2-git-send-email-zapped@mail.ru>
Alexey Shumkin <alex.crezoff@gmail.com> writes:
Show 5 quoted lines
> git log --graph --oneline
> and
> git log --graph --pretty=format:'%C(yellow)%h %Creset%s'
> give different outputs on Linux UTF-8 console
> when commit messages contain non-UTF-8 characters

(content) "different" is not specific enough to describe a problem (in some cases, difference in command line arguments is the way to obtain different results), especially if you do not state that they "should" be the same to begin with, and preferrably under what condition they should be the same.

(content) Do you really need all of the above options to observe the breakage, or can you drop --graph? If so, drop it from the proposed commit log message, as it is distracting without merit.

(content) Do you really mean SP before %Creset, not after?

(style) Somehow I find this hard to read. Perhaps make the two "sample commands" stand out more from the surrounding text? E.g.

-- >8 -- The following two ought to give the same output to a terminal:

	$ git log --oneline
        $ git log --pretty=format:'%C(yellow)%h %creset%s'

However, the former pays attention to i18n.logOutputEncoding configuration, while the latter does not when it format "%s". A log messages written in an encoding i18n.commitEncoding that is not UTF-8 is shown corrupted with the latter even when i18n.logOutputEncoding is set to convert to UTF-8.

Signed-off-by: ...
-- 8< --

(question) Does this change affect other commands, most notably format-patch, and if so how?

Show 52 quoted lines
> diff --git a/log-tree.c b/log-tree.c
> index e945701..39913d7 100644
> --- a/log-tree.c
> +++ b/log-tree.c
> @@ -488,6 +488,7 @@ void show_log(struct rev_info *opt)
>  	ctx.preserve_subject = opt->preserve_subject;
>  	ctx.reflog_info = opt->reflog_info;
>  	ctx.fmt = opt->commit_format;
> +	ctx.output_encoding = get_log_output_encoding();
>  	pretty_print_commit(&ctx, commit, &msgbuf);
>  
>  	if (opt->add_signoff)
> diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
> index 2ae9faa..24e787a 100755
> --- a/t/t4205-log-pretty-formats.sh
> +++ b/t/t4205-log-pretty-formats.sh
> @@ -11,10 +11,12 @@ test_expect_success 'set up basic repos' '
>  	>bar &&
>  	git add foo &&
>  	test_tick &&
> -	git commit -m initial &&
> +	git config i18n.commitEncoding cp1251 &&
> +	printf "initial \320\272\320\276\320\274\320\274\320\270\321\202" | iconv -t cp1251 -f utf-8 | xargs -I{} git commit -m "{}" &&
>  	git add bar &&
>  	test_tick &&
> -	git commit -m "add bar"
> +	git commit -m "add bar" &&
> +	git config --unset i18n.commitEncoding
>  '
>  
>  test_expect_success 'alias builtin format' '
> @@ -38,6 +40,20 @@ test_expect_success 'alias user-defined format' '
>  	test_cmp expected actual
>  '
>  
> +test_expect_success 'alias user-defined tformat with %s (native encoding)' '
> +	git config i18n.logOutputEncoding cp1251 &&
> +	git log --oneline >expected-s &&
> +	git log --pretty="tformat:%h %s" >actual-s &&
> +	git config --unset i18n.logOutputEncoding &&
> +	test_cmp expected-s actual-s
> +'
> +
> +test_expect_success 'alias user-defined tformat with %s (utf-8 encoding)' '
> +	git log --oneline >expected-s &&
> +	git log --pretty="tformat:%h %s" >actual-s &&
> +	test_cmp expected-s actual-s
> +'
> +
>  test_expect_success 'alias user-defined tformat' '
>  	git log --pretty="tformat:%h" >expected &&
>  	git config pretty.test-alias "tformat:%h" &&
Previous: Alexey ShumkinNext: Alexey Shumkin
Message 3 of 12 in “pretty: user format ignores i18n.logOutputEncoding setting”
  1. pretty: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Jul 25, 2011
  2. pretty: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Jul 25, 2011
  3. Junio C HamanoJul 25, 2011
  4. Alexey ShumkinJul 26, 2011
  5. pretty: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Sep 9, 2011
  6. 1/2 pretty: Add failing tests: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Sep 9, 2011
  7. 2/2 pretty: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Sep 9, 2011
  8. pretty: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Sep 9, 2011
  9. 1/2 pretty: Add failing tests: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Sep 9, 2011
  10. Junio C HamanoSep 9, 2011
  11. 0/2 pretty: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Sep 20, 2011
  12. 2/2 pretty: user format ignores i18n.logOutputEncoding settingAlexey Shumkin, Sep 9, 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.