From: Lars Schneider <larsxschneider@gmail.com>
To: Eric Sunshine <sunshine@sunshineco.com>
Cc: "Lars Schneider" <lars.schneider@autodesk.com>,
"Git List" <git@vger.kernel.org>,
"Junio C Hamano" <gitster@pobox.com>,
"Torsten Bögershausen" <tboegi@web.de>,
"Johannes Sixt" <j6t@kdbg.org>, "Jeff King" <peff@peff.net>,
"Ramsay Jones" <ramsay@ramsayjones.plus.com>,
"Johannes Schindelin" <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH v9 5/8] convert: add 'working-tree-encoding' attribute
Date: Tue, 6 Mar 2018 23:13:24 +0100 [thread overview]
Message-ID: <570D707A-DD9E-4397-8155-E8B3C3D09760@gmail.com> (raw)
In-Reply-To: <CAPig+cTOpBODeoHV=+4-4MEjKM=pUrZSa=BEmHh4mVP=xPpFCA@mail.gmail.com>
> On 06 Mar 2018, at 21:42, Eric Sunshine <sunshine@sunshineco.com> wrote:
>
> On Sun, Mar 4, 2018 at 3:14 PM, <lars.schneider@autodesk.com> wrote:
>> Git recognizes files encoded with ASCII or one of its supersets (e.g.
>> UTF-8 or ISO-8859-1) as text files. All other encodings are usually
>> interpreted as binary and consequently built-in Git text processing
>> tools (e.g. 'git diff') as well as most Git web front ends do not
>> visualize the content.
>> [...]
>> Signed-off-by: Lars Schneider <larsxschneider@gmail.com>
>> ---
>> diff --git a/convert.c b/convert.c
>> @@ -978,6 +1051,25 @@ static int ident_to_worktree(const char *path, const char *src, size_t len,
>> +static const char *git_path_check_encoding(struct attr_check_item *check)
>> +{
>> + [...]
>> + /*
>> + * Ensure encoding names are always upper case (e.g. UTF-8) to
>> + * simplify subsequent string comparisons.
>> + */
>> + return xstrdup_toupper(value);
>
> xstrdup_toupper() allocates memory...
>
>> +}
>> @@ -1033,6 +1125,7 @@ struct conv_attrs {
>> enum crlf_action attr_action; /* What attr says */
>> enum crlf_action crlf_action; /* When no attr is set, use core.autocrlf */
>> int ident;
>> + const char *working_tree_encoding; /* Supported encoding or default encoding if NULL */
>
> ...which is assigned to 'const char *'...
>
>> };
>> @@ -1064,6 +1158,7 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)
>> else if (eol_attr == EOL_CRLF)
>> ca->crlf_action = CRLF_TEXT_CRLF;
>> }
>> + ca->working_tree_encoding = git_path_check_encoding(ccheck + 5);
>
> ...by this code, and eventually leaked.
>
> It's too bad it isn't cleaned up (freed), but looking at the callers,
> fixing this leak would be mildly noisy (though not particularly
> invasive). How much do we care about this leak?
Hmm. You are right. That was previously handled by the encoding struct
linked list that I removed in this iteration. I forgot about that aspect :/
I don't like it leaking. I think I would like to reintroduce the linked
list. This way every encoding is only once in memory. What do you think?
>> } else {
>> ca->drv = NULL;
>> ca->crlf_action = CRLF_UNDEFINED;
>> diff --git a/t/t0028-working-tree-encoding.sh b/t/t0028-working-tree-encoding.sh
>> @@ -0,0 +1,135 @@
>> +test_expect_success 'check $GIT_DIR/info/attributes support' '
>> + test_when_finished "rm -f test.utf8.raw test.utf32.raw test.utf32.git" &&
>
> It seems weird to be cleaning up files this test didn't create
> (test.utf8.raw and test.utf32.raw).
Agreed.
>> + test_when_finished "git reset --hard HEAD" &&
>> +
>> + echo "*.utf32 text working-tree-encoding=utf-32" >.git/info/attributes &&
>> + git add test.utf32 &&
>> +
>> + git cat-file -p :test.utf32 >test.utf32.git &&
>> + test_cmp_bin test.utf8.raw test.utf32.git
>> +'
>> +
>> +test_expect_success 'check unsupported encodings' '
>> + test_when_finished "rm -f err.out" &&
>> + test_when_finished "git reset --hard HEAD" &&
>
> Resetting to HEAD here is an important cleanup action, but tests don't
> usually clean up files such as 'err.out' since such detritus doesn't
> usually impact subsequent tests negatively. (Just an observation; no
> re-roll needed.)
OK. I'll fix it if I reroll.
- Lars
next prev parent reply other threads:[~2018-03-06 22:13 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-04 20:14 [PATCH v9 0/8] convert: add support for different encodings lars.schneider
2018-03-04 20:14 ` [PATCH v9 1/8] strbuf: remove unnecessary NUL assignment in xstrdup_tolower() lars.schneider
2018-03-04 20:14 ` [PATCH v9 2/8] strbuf: add xstrdup_toupper() lars.schneider
2018-03-04 20:14 ` [PATCH v9 3/8] utf8: add function to detect prohibited UTF-16/32 BOM lars.schneider
2018-03-04 20:14 ` [PATCH v9 4/8] utf8: add function to detect a missing " lars.schneider
2018-03-06 20:50 ` Junio C Hamano
2018-03-06 22:39 ` Lars Schneider
2018-03-06 22:53 ` Junio C Hamano
2018-03-06 23:00 ` Lars Schneider
2018-03-06 23:07 ` Junio C Hamano
2018-03-06 23:12 ` Lars Schneider
2018-03-06 23:37 ` Junio C Hamano
2018-03-07 17:39 ` Torsten Bögershausen
2018-03-04 20:14 ` [PATCH v9 5/8] convert: add 'working-tree-encoding' attribute lars.schneider
2018-03-06 20:42 ` Eric Sunshine
2018-03-06 22:13 ` Lars Schneider [this message]
2018-03-06 22:22 ` Eric Sunshine
2018-03-04 20:14 ` [PATCH v9 6/8] convert: check for detectable errors in UTF encodings lars.schneider
2018-03-05 21:50 ` Junio C Hamano
2018-03-05 23:45 ` Lars Schneider
2018-03-06 1:23 ` Junio C Hamano
2018-03-06 17:03 ` Lars Schneider
2018-03-06 20:55 ` Eric Sunshine
2018-03-04 20:14 ` [PATCH v9 7/8] convert: add tracing for 'working-tree-encoding' attribute lars.schneider
2018-03-04 20:14 ` [PATCH v9 8/8] convert: add round trip check based on 'core.checkRoundtripEncoding' lars.schneider
2018-03-06 21:05 ` [PATCH v9 0/8] convert: add support for different encodings 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=570D707A-DD9E-4397-8155-E8B3C3D09760@gmail.com \
--to=larsxschneider@gmail.com \
--cc=Johannes.Schindelin@gmx.de \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=lars.schneider@autodesk.com \
--cc=peff@peff.net \
--cc=ramsay@ramsayjones.plus.com \
--cc=sunshine@sunshineco.com \
--cc=tboegi@web.de \
/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).