git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Alexey Shumkin <Alex.Crezoff@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v5 5/5] pretty: user format ignores i18n.logOutputEncoding setting
Date: Thu, 20 Jun 2013 13:37:34 -0700	[thread overview]
Message-ID: <7v8v24selt.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <ed75c8cbcfbbac336e2384e2f566e42264154918.1371720245.git.Alex.Crezoff@gmail.com> (Alexey Shumkin's message of "Thu, 20 Jun 2013 13:26:21 +0400")

Alexey Shumkin <Alex.Crezoff@gmail.com> writes:

Subject: Re: [PATCH v5 5/5] pretty: user format ignores i18n.logOutputEncoding setting

That is a statement of fact, and does not tell much to the reader.

I think you are saying that in the current implementation,
logoutputencoding is not honored in user format, that it is a bug
that needs to be fixed (as opposed to "that is by design, the
scripts that read from --format='' is responsible for doing the
conversion"), and that this patch fixes it.

So

	pretty: --format output should honor logOutputEncoding

or something?  At least it says what is the _desired_ outcome with
"should", hints that the status-quo is different from that desired
outcome and implies that this is a patch to fix it.

The "Subject" line is very important as that is the only thing we
see in many summarizing output format, e.g. shortlog, cover letter
and merge message.

> The following two commands are expected to give the same output to a terminal:
>
> 	$ git log --oneline --no-color
> 	$ git log --pretty=format:'%h %s'
>
> However, the former pays attention to i18n.logOutputEncoding
> configuration, while the latter does not when it format "%s".
> Log messages written in an encoding i18n.commitEncoding which differs
> from terminal encoding are shown corrupted with the latter even
> when i18n.logOutputEncoding and terminal encoding are the same.
>
> The same corruption is true for
> 	$ git diff --submodule=log
> and
> 	$ git rev-list --pretty=format:%s HEAD
> and
> 	$ git reset --hard
>
> Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
> ---
>  builtin/reset.c                  |  8 ++++++--
>  builtin/rev-list.c               |  1 +
>  builtin/shortlog.c               |  1 +
>  log-tree.c                       |  1 +
>  submodule.c                      |  3 +++
>  t/t4041-diff-submodule-option.sh | 10 +++++-----
>  t/t4205-log-pretty-formats.sh    | 34 +++++++++++++++++-----------------
>  t/t6006-rev-list-format.sh       |  8 ++++----
>  t/t7102-reset.sh                 |  2 +-
>  9 files changed, 39 insertions(+), 29 deletions(-)
>
> diff --git a/builtin/reset.c b/builtin/reset.c
> index 6032131..b23ed63 100644
> --- a/builtin/reset.c
> +++ b/builtin/reset.c
> @@ -92,11 +92,15 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
>  
>  static void print_new_head_line(struct commit *commit)
>  {
> -	const char *hex, *body;
> +	const char *hex, *body, *encoding;
>  
>  	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
>  	printf(_("HEAD is now at %s"), hex);
> -	body = strstr(commit->buffer, "\n\n");
> +	encoding = get_log_output_encoding();
> +	body = logmsg_reencode(commit, NULL, encoding);


> +	if (!body)
> +		body = commit->buffer;

Does this happen?  I thought body, without an error, can be the same
as commit->buffer.

> +	body = strstr(body, "\n\n");
>  	if (body) {
>  		const char *eol;
>  		size_t len;

Do we have a leak here?  body may point at a new piece of memory
logmsg_reencode() have allocated to hold the UTF-8 version of your
8859-5 message in commit->buffer.

It would be more like this, no?

diff --git a/builtin/reset.c b/builtin/reset.c
index 6032131..8d22ffe 100644
--- a/builtin/reset.c
+++ b/builtin/reset.c
@@ -92,11 +92,13 @@ static int reset_index(const unsigned char *sha1, int reset_type, int quiet)
 
 static void print_new_head_line(struct commit *commit)
 {
-	const char *hex, *body;
+	const char *hex, *body, *msg, *encoding; 
 
 	hex = find_unique_abbrev(commit->object.sha1, DEFAULT_ABBREV);
 	printf(_("HEAD is now at %s"), hex);
-	body = strstr(commit->buffer, "\n\n");
+
+	msg = logmsg_reencode(commit, NULL, get_log_output_encoding());
+	body = strstr(msg, "\n\n");
 	if (body) {
 		const char *eol;
 		size_t len;
@@ -107,6 +109,7 @@ static void print_new_head_line(struct commit *commit)
 	}
 	else
 		printf("\n");
+	logmsg_free(msg, commit);
 }
 
 static void update_index_from_diff(struct diff_queue_struct *q,

  reply	other threads:[~2013-06-20 20:37 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-22  7:06 git log --oneline and git log --pretty=format... give differrent outputs Shumkin Alexey
2011-07-22  7:53 ` Alexey Shumkin
2011-07-25 10:31   ` [PATCH] pretty: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2011-07-25 10:31     ` Alexey Shumkin
2011-07-25 19:45       ` Junio C Hamano
2011-07-26 13:18         ` Alexey Shumkin
2011-09-09  8:43         ` [PATCH v2] " Alexey Shumkin
2011-09-09  8:43           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-09  8:43           ` [PATCH 2/2] pretty: " Alexey Shumkin
2011-09-09  8:53         ` [PATCH v2] " Alexey Shumkin
2011-09-09  8:53           ` [PATCH 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-09 22:54             ` Junio C Hamano
2011-09-20  8:20               ` [PATCH v3 0/2] pretty: " Alexey Shumkin
2011-09-20  8:21               ` [PATCH v3 1/2] pretty: Add failing tests: " Alexey Shumkin
2011-09-20 19:12                 ` Junio C Hamano
2011-09-20 20:46                   ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 0/4] Reroll patches against v1.8.1.1 Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 0/5] Reroll patches against v1.8.3.1 Alexey Shumkin
2013-06-20 20:10                         ` Junio C Hamano
2013-06-25  8:55                         ` [PATCH v6 " Alexey Shumkin
2013-06-25 19:28                           ` Junio C Hamano
2013-06-26  7:37                             ` Alexey Shumkin
2013-06-26 14:24                               ` Junio C Hamano
2013-06-26 10:19                           ` [PATCH v7 " Alexey Shumkin
2013-06-26 16:19                             ` Junio C Hamano
2013-07-01 23:18                             ` [PATCH v8 0/5] Reroll patches against Git v1.8.3.2 Alexey Shumkin
2013-07-02 19:41                               ` Junio C Hamano
2013-07-03 20:03                                 ` Alexey Shumkin
2013-07-03 20:06                                   ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 0/5] Incremental updates against 'next' branch Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 " Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 2/5] t4205 (log-pretty-formats): revert back single quotes Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 3/5] t4205, t6006, t7102: make functions better readable Alexey Shumkin
2013-07-05 18:38                                   ` Junio C Hamano
2013-07-05 18:45                                     ` Junio C Hamano
2013-07-05 12:01                                 ` [PATCH v10 4/5] t6006 (rev-list-format): add tests for "%b" and "%s" for the case i18n.commitEncoding is not set Alexey Shumkin
2013-07-05 12:01                                 ` [PATCH v10 5/5] t4205 (log-pretty-formats): avoid using `sed` Alexey Shumkin
2013-07-04 12:45                               ` [PATCH v9 1/5] t4041, t4205, t6006, t7102: use iso8859-1 rather than iso-8859-1 Alexey Shumkin
2013-07-05  6:47                                 ` Junio C Hamano
2013-07-05  8:00                                   ` Alexey Shumkin
2013-07-05  8:11                                     ` Junio C Hamano
2013-07-05  8:42                                       ` Alexey Shumkin
2013-07-05  8:56                                         ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 2/5] t4205: revert back single quotes Alexey Shumkin
2013-07-05  7:07                                 ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 3/5] t4205, t6006, t7102: make functions more readable Alexey Shumkin
2013-07-05  6:45                                 ` Junio C Hamano
2013-07-05  8:13                                   ` Alexey Shumkin
2013-07-05  8:44                                     ` Junio C Hamano
2013-07-05  8:51                                       ` Alexey Shumkin
2013-07-05  8:58                                         ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 4/5] t6006: add two more tests for the case i18n.commitEncoding is not set Alexey Shumkin
2013-07-05  6:52                                 ` Junio C Hamano
2013-07-05  7:04                                 ` Junio C Hamano
2013-07-05  7:46                                   ` Alexey Shumkin
2013-07-05  8:09                                     ` Junio C Hamano
2013-07-04 12:45                               ` [PATCH v9 5/5] t4205: avoid using `sed` Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 2/5] t7102 (reset): " Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-07-01 23:19                             ` [PATCH v8 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-07-02  6:46                               ` Johannes Sixt
2013-07-01 23:19                             ` [PATCH v8 5/5] pretty: " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 2/5] t7102 (reset): " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-07-01  7:00                             ` Johannes Sixt
2013-07-01 22:50                               ` Alexey Shumkin
2013-07-02  7:22                                 ` Johannes Sixt
2013-07-03 20:20                                   ` Alexey Shumkin
2013-06-26 10:19                           ` [PATCH v7 5/5] pretty: " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 2/5] t7102 (reset): " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 4/5] pretty: Add failing tests: --format output should honor logOutputEncoding Alexey Shumkin
2013-06-25  8:55                         ` [PATCH v6 5/5] pretty: " Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 1/5] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-06-20 20:38                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 2/5] t7102 (reset): " Alexey Shumkin
2013-06-20  9:26                       ` [PATCH v5 3/5] t4205 (log-pretty-formats): " Alexey Shumkin
2013-06-20 20:38                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 4/5] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2013-06-20 20:23                         ` Junio C Hamano
2013-06-20  9:26                       ` [PATCH v5 5/5] pretty: " Alexey Shumkin
2013-06-20 20:37                         ` Junio C Hamano [this message]
2013-01-24  9:10                     ` [PATCH v4 1/4] t6006 (rev-list-format): don't hardcode SHA-1 in expected outputs Alexey Shumkin
2013-01-24 20:29                       ` Junio C Hamano
2013-01-25  9:20                         ` Alexey Shumkin
2013-01-25 11:06                         ` Alexey Shumkin
2013-01-25 15:16                           ` Junio C Hamano
2013-01-25 15:27                             ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 2/4] t7102 (reset): refactoring: " Alexey Shumkin
2013-01-24 20:30                       ` Junio C Hamano
2013-01-25  9:08                         ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 3/4] pretty: Add failing tests: user format ignores i18n.logOutputEncoding setting Alexey Shumkin
2013-01-24 20:44                       ` Junio C Hamano
2013-01-25  9:07                         ` Alexey Shumkin
2013-01-24 21:02                       ` Junio C Hamano
2013-01-25  9:01                         ` Alexey Shumkin
2013-01-24  9:10                     ` [PATCH v4 4/4] pretty: " Alexey Shumkin
2011-09-20  8:21               ` [PATCH v3 2/2] " Alexey Shumkin
2011-09-09  8:53           ` [PATCH " Alexey Shumkin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7v8v24selt.fsf@alter.siamese.dyndns.org \
    --to=gitster@pobox.com \
    --cc=Alex.Crezoff@gmail.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).