All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Russell, Scott" <Scott.Russell2@ncr.com>
Cc: "brian m. carlson" <sandals@crustytoothpaste.net>,
	"git@vger.kernel.org" <git@vger.kernel.org>
Subject: Re: git clone corrupts file.
Date: Mon, 16 Aug 2021 14:49:23 -0400	[thread overview]
Message-ID: <YRqzM1D6w4bDYjKY@coredump.intra.peff.net> (raw)
In-Reply-To: <BN6PR15MB1426D70E338F6B2A988565A9CBFD9@BN6PR15MB1426.namprd15.prod.outlook.com>

On Mon, Aug 16, 2021 at 05:39:12PM +0000, Russell, Scott wrote:

> We don't want any EOL handling of any file.  That's why we specify autocrlf false.

Right, but it's not the whole story. autocrlf is an older and broader
mechanism for doing line-ending conversion. From its documentation in
"git help config":

  core.autocrlf
    Setting this variable to "true" is the same as setting the text
    attribute to "auto" on all files and core.eol to "crlf".[...]

You obviously don't want that, but you _also_ don't want to set the text
and eol attributes on individual paths, either.

> We would like git to not any cr lf conversion on any file.   Whether
> they be ANSI or Unicode.   They had the right endings when we checked
> them in.
> We don't want them adjusted.
> 
> Does removing the eol = cr lf fix that?

That might be sufficient. You may also need to drop "text", as well.
Otherwise core.eol will kick in and do conversions. (Sorry, I don't use
Windows and it has been a long time since I looked into these options,
so you may have to do some experimenting).

> 	You said:  UTF-16 ...  can't be treated as "text" by Git.
> 
> We can't make any changes to the files to suit git.   We just need git to store and retrieve files as committed.

Right. That's what it does by default (if you don't set any .gitattributes).

What I mean by "can't be treated as text" is that Git will not correctly
implement text features like CRLF conversion, nor diffs, for such an
encoding. It is effectively a binary file from Git's perspective.

> Will removing the 
> 
> 	eol=cr lf 
> 
> from the line 
> 
> *.ini text 
> 
> from the attributes file stop the issue?
> 
> If not, does .gitattributes allow a path?  Such that we could say 
> 
> \config\Language Specific\*   type  -    If these are Unicode, what would we say here.   Can it not be text?  Then binary?  
> *.ini	text

If you simply drop the attributes entirely, Git will use its
auto-detection to determine whether a file is binary, which looks for
NULs (and UTF-16 files are generally full of them). So I suspect that
would do it. You can also provide the "-text" attribute to override that
and make sure no line-ending conversion is done.

If you want to override a specific file, then yes, you can provide paths
(I don't recall offhand whether we allow backslashes in the patterns;
you may need to use forward slashes). You can also put the pattern "*"
in the "config/Language Specific/.gitattributes" to have it apply only
to that directory (and ones below it).

The patterns are the same as those in .gitignore files; see the section
"PATTERN FORMAT" in "git help ignore".

-Peff

  reply	other threads:[~2021-08-16 18:49 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 [this message]
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
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=YRqzM1D6w4bDYjKY@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=Scott.Russell2@ncr.com \
    --cc=git@vger.kernel.org \
    --cc=sandals@crustytoothpaste.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.