git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lars Schneider <larsxschneider@gmail.com>
To: "Torsten Bögershausen" <tboegi@web.de>
Cc: Lars Schneider <lars.schneider@autodesk.com>,
	git@vger.kernel.org, gitster@pobox.com, j6t@kdbg.org,
	sunshine@sunshineco.com, peff@peff.net,
	ramsay@ramsayjones.plus.com, Johannes.Schindelin@gmx.de
Subject: Re: [PATCH v6 5/7] convert: add 'working-tree-encoding' attribute
Date: Wed, 14 Feb 2018 14:22:13 +0100	[thread overview]
Message-ID: <E13489D5-5BED-4C30-A153-4146822C3DC6@gmail.com> (raw)
In-Reply-To: <20180210094852.GB11525@tor.lan>


> On 10 Feb 2018, at 10:48, Torsten Bögershausen <tboegi@web.de> wrote:
> 
> On Fri, Feb 09, 2018 at 02:28:28PM +0100, lars.schneider@autodesk.com wrote:
>> From: Lars Schneider <larsxschneider@gmail.com>
>> 
>> ...
>> 
>> +Please note that using the `working-tree-encoding` attribute may have a
>> +number of pitfalls:
>> +
>> +- Git clients that do not support the `working-tree-encoding` attribute
> 
> A client to Git ?
> Or may be "third party Git implementations"

OK, I'll go with "Third party Git implementations".


>> 
>> +As an example, use the following attributes if your '*.proj' files are
>> +UTF-16 encoded with byte order mark (BOM) and you want Git to perform
>> +automatic line ending conversion based on your platform.
>> +
>> +------------------------
>> +*.proj		text working-tree-encoding=UTF-16
>> +------------------------
>> +
>> +Use the following attributes if your '*.proj' files are UTF-16 little
>> +endian encoded without BOM and you want Git to use Windows line endings
>> +in the working directory. Please note, it is highly recommended to
>> +explicitly define the line endings with `eol` if the `working-tree-encoding`
>> +attribute is used to avoid ambiguity.
>> +
>> +------------------------
>> +*.proj 		working-tree-encoding=UTF-16LE text eol=CRLF
>> +------------------------
>> +
>> +You can get a list of all available encodings on your platform with the
>> +following command:
> 
> One question:
> +*.proj		text working-tree-encoding=UTF-16
> vs
> *.proj 		working-tree-encoding=UTF-16LE text eol=CRLF
> 
> Technically the order of attributes doesn't matter, but that is not what we
> want to demonstrate here and now.
> I would probably move the "text" attribute to the end of the line.
> So that readers don't start to wonder if the order is important.

I agree in general. However, I would move "text" to the beginning to be
consistent with the gitattribute pattern above. OK?


>> 
>> +	if (has_prohibited_utf_bom(enc->name, src, src_len)) {
>> +		const char *error_msg = _(
>> +			"BOM is prohibited for '%s' if encoded as %s");
>> +		const char *advise_msg = _(
>> +			"You told Git to treat '%s' as %s. A byte order mark "
>> +			"(BOM) is prohibited with this encoding. Either use "
>> +			"%.6s as working tree encoding or remove the BOM from the "
>> +			"file.");
> 
> "You told Git" is probly right from Gits point of view, and advises are really helpfull.
> But what should the user do about it ?
> Could we give a better advise ?
> 
> 
> "A byte order mark (BOM) is prohibited with %s.
> Please remove the BOM from the file %s 
> or use "%s as working-tree-encoding"
> 
> I would probably suspect that a tool wrote the BOM, and that is
> good and can or should not be changed by a user.
> 
> So a simply message like this could be the preferred (and only)
> solution for a user:
> "A byte order mark (BOM) is prohibited with %s.
> Please use "%s as working-tree-encoding"

OK. I like the last one!


> (And why %.6s and not simply %s ?)

The encodings is UTF-16LE, UTF-16BE, UTF-32LE, or UTF-32BE.
I just use the first 6 characters to print the encoding that
allows BOMs (UTF-16 or UTF-32). I'll add a comment to explain 
the trickery in the code!

Thanks,
Lars

  reply	other threads:[~2018-02-14 13:22 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-09 13:28 [PATCH v6 0/7] convert: add support for different encodings lars.schneider
2018-02-09 13:28 ` [PATCH v6 1/7] strbuf: remove unnecessary NUL assignment in xstrdup_tolower() lars.schneider
2018-02-09 13:28 ` [PATCH v6 2/7] strbuf: add xstrdup_toupper() lars.schneider
2018-02-09 13:28 ` [PATCH v6 3/7] utf8: add function to detect prohibited UTF-16/32 BOM lars.schneider
2018-02-09 13:28 ` [PATCH v6 4/7] utf8: add function to detect a missing " lars.schneider
2018-02-09 19:28   ` Junio C Hamano
2018-02-09 19:47     ` Lars Schneider
2018-02-09 13:28 ` [PATCH v6 5/7] convert: add 'working-tree-encoding' attribute lars.schneider
2018-02-10  9:48   ` Torsten Bögershausen
2018-02-14 13:22     ` Lars Schneider [this message]
2018-02-09 13:28 ` [PATCH v6 6/7] convert: add tracing for " lars.schneider
2018-02-09 13:28 ` [PATCH v6 7/7] convert: add round trip check based on 'core.checkRoundtripEncoding' lars.schneider
2018-02-09 20:09 ` [PATCH v6 0/7] convert: add support for different encodings Junio C Hamano
2018-02-10  1:04   ` Lars Schneider

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

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

  git send-email \
    --in-reply-to=E13489D5-5BED-4C30-A153-4146822C3DC6@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.
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 NNTP newsgroup(s).