From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: "Łukasz Stelmach" <l.stelmach@samsung.com>
Cc: git@vger.kernel.org, "Stefan Beller" <sbeller@google.com>,
"Pat Thoyts" <patthoyts@users.sourceforge.net>,
"Łukasz Stelmach" <stlman@poczta.fm>
Subject: Re: [PATCH v2] git-gui: Prevent double UTF-8 conversion
Date: Mon, 4 Dec 2017 15:31:22 +0100 (CET) [thread overview]
Message-ID: <alpine.DEB.2.21.1.1712041521330.98586@virtualbox> (raw)
In-Reply-To: <20171202122046.6033-1-l.stelmach@samsung.com>
[-- Attachment #1: Type: text/plain, Size: 2457 bytes --]
Hi Łukasz,
On Sat, 2 Dec 2017, Łukasz Stelmach wrote:
> Convert author's name from the UTF-8 (or any other) encoding in
> load_last_commit function the same way commit message is converted.
>
> Amending commits in git-gui without such conversion breaks UTF-8
> strings. For example, "\305\201ukasz" (as written by git cat-file) becomes
> "\303\205\302\201ukasz" in an amended commit.
Okay, that makes the issue a lot clearer to me (the explicit mention of
"author's name", that is).
> diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl
> index 83620b7cb..f820c24bf 100644
> --- a/git-gui/lib/commit.tcl
> +++ b/git-gui/lib/commit.tcl
> @@ -34,9 +34,7 @@ You are currently in the middle of a merge that has not been fully completed. Y
> lappend parents [string range $line 7 end]
> } elseif {[string match {encoding *} $line]} {
> set enc [string tolower [string range $line 9 end]]
> - } elseif {[regexp "author (.*)\\s<(.*)>\\s(\\d.*$)" $line all name email time]} {
> - set commit_author [list name $name email $email date $time]
> - }
> + } elseif {[regexp "author (.*)\\s<(.*)>\\s(\\d.*$)" $line all name email time]} { }
> }
This looks wrong, as the commit_author would now also be set if the header
was not found (mind you, this would make for an incorrect Git commit, but
the code explicitly tries to set commit_author only in the case that the
author line was found.
But we cannot set commit_author here because the encoding is read as
another header line (and in a valid commit object, the encoding line (if
any) has to be *below* the author line).
So it *has* to be this way. Maybe mention this in the commit message, to
avoid head-scratching?
However, I would still recommend to `set name ""` before the loop parsing
the header, and...
> set msg [read $fd]
> close $fd
> @@ -44,7 +42,9 @@ You are currently in the middle of a merge that has not been fully completed. Y
> set enc [tcl_encoding $enc]
> if {$enc ne {}} {
> set msg [encoding convertfrom $enc $msg]
> + set name [encoding convertfrom $enc $name]
> }
> + set commit_author [list name $name email $email date $time]
Guarding this assignment in an `if {$name ne ""} { ... }`, just in case.
> set msg [string trim $msg]
> } err]} {
> error_popup [strcat [mc "Error loading commit data for amend:"] "\n\n$err"]
Thanks,
Johannes
next prev parent reply other threads:[~2017-12-04 14:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20171128102138eucas1p116ae54d723bb100202fae2c1aaf5a9d8@eucas1p1.samsung.com>
2017-11-28 10:21 ` [PATCH] git-gui: Prevent double UTF-8 conversion Łukasz Stelmach
2017-11-28 14:35 ` Johannes Schindelin
2017-12-02 10:33 ` Łukasz Stelmach
2017-12-02 12:20 ` [PATCH v2] " Łukasz Stelmach
2017-12-04 14:31 ` Johannes Schindelin [this message]
[not found] ` <CGME20171205142341eucas1p2b30072c799c8787f1b66db2fd4bac1a2@eucas1p2.samsung.com>
2017-12-05 14:23 ` [PATCH v3] " Łukasz Stelmach
2017-12-07 0:06 ` Johannes Schindelin
[not found] ` <CGME20171214093300eucas1p28ed9bf0261a43a12978b6a3bfe908321@eucas1p2.samsung.com>
2017-12-14 9:32 ` [PATCH v4] " Łukasz Stelmach
2017-12-14 9:42 ` Eric Sunshine
[not found] ` <CGME20171214104348eucas1p2921cdc8df00c90055927ec99eba3040a@eucas1p2.samsung.com>
2017-12-14 10:43 ` Łukasz Stelmach
2017-12-14 18:18 ` Eric Sunshine
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=alpine.DEB.2.21.1.1712041521330.98586@virtualbox \
--to=johannes.schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=l.stelmach@samsung.com \
--cc=patthoyts@users.sourceforge.net \
--cc=sbeller@google.com \
--cc=stlman@poczta.fm \
/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).