public inbox for git@vger.kernel.org 
 help / color / mirror / Atom feed
From: "brian m. carlson" <sandals@crustytoothpaste•net>
To: Jeff King <peff@peff•net>
Cc: "Russell, Scott" <Scott.Russell2@ncr•com>,
	"git@vger•kernel.org" <git@vger•kernel.org>
Subject: Re: git clone corrupts file.
Date: Mon, 16 Aug 2021 21:50:35 +0000	[thread overview]
Message-ID: <YRrdq5VAp3o35+Fb@camp.crustytoothpaste.net> (raw)
In-Reply-To: <YRqzmC5ubd0TEWL/@coredump.intra.peff.net>

[-- Attachment #1: Type: text/plain, Size: 1578 bytes --]

On 2021-08-16 at 18:51:04, Jeff King wrote:
> On Mon, Aug 16, 2021 at 12:53:36PM -0400, Jeff King wrote:
> 
> > But an alternative workflow, if you really want UTF-16 in the working
> > tree, is to convert between UTF-8 and UTF-16 as the files go in and out
> > o the working tree. There's no built-in support for that, but you could
> > do it with a custom clean/smudge filter. That would let Git store UTF-8
> > internally, do diffs, etc.
> 
> Oh, by the way, I totally forgot that we added an internal version of
> this, which is easier to configure and much more efficient. See the
> "working-tree-encoding" attribute in "git help attributes".
> 
> Just in case you do want to go that route.

The specific information you need is located in the Git FAQ[0], but
roughly, you would probably want something like this:

*.h text lf=crlf working-tree-encoding=UTF-16LE-BOM

That means that when checked out, the file will be in the format that
legacy Windows programs prefer (CRLF with little-endian UTF-16 with a
BOM), but will be stored internally in Git with LF and UTF-8.  That will
make things like git diff work much better, but still permit things to
be in the working tree as you wish.

If you really don't want those to be modified at all, then you'd want to
write this:

*.h -text

However, Git will consider these files to be binary, since they are, and
git diff won't work on them without a textconv filter.

[0] https://git-scm.com/docs/gitfaq#windows-text-binary
-- 
brian m. carlson (he/him or they/them)
Toronto, Ontario, CA

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 262 bytes --]

  parent reply	other threads:[~2021-08-16 21:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <BN6PR15MB1426E50F03A0530CA9140F98CBFA9@BN6PR15MB1426.namprd15.prod.outlook.com>
     [not found] ` <BN6PR15MB14261C40E614CC11416388B4CBFA9@BN6PR15MB1426.namprd15.prod.outlook.com>
2021-08-13 18:54   ` git clone corrupts file Russell, Scott
2021-08-13 22:30     ` brian m. carlson
2021-08-16 15:24       ` Russell, Scott
2021-08-16 16:53         ` Jeff King
2021-08-16 17:39           ` Russell, Scott
2021-08-16 18:49             ` Jeff King
2021-08-16 18:52               ` Russell, Scott
2021-08-16 18:51           ` Jeff King
2021-08-16 18:53             ` Russell, Scott
2021-08-16 21:50             ` brian m. carlson [this message]
2021-08-16 22:04               ` Russell, Scott
2021-08-16 22:19                 ` brian m. carlson
2021-08-16 22:26                   ` Russell, Scott

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=YRrdq5VAp3o35+Fb@camp.crustytoothpaste.net \
    --to=sandals@crustytoothpaste$(echo .)net \
    --cc=Scott.Russell2@ncr$(echo .)com \
    --cc=git@vger$(echo .)kernel.org \
    --cc=peff@peff$(echo .)net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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