git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* How to have EOL=LF and keep binary files auto-detection?
@ 2016-04-25 14:11 Kirill Likhodedov
  2016-04-25 16:46 ` Torsten Bögershausen
  0 siblings, 1 reply; 3+ messages in thread
From: Kirill Likhodedov @ 2016-04-25 14:11 UTC (permalink / raw)
  To: git
  Cc: Николай Чашников

Hi, 

I wonder if it is possible both to have LFs in all and only text files in working trees, and keep Git’s binary files auto-detection?

To be more precise:
* we want all text files to be checked out in LF; 
* we don’t want force people to set “core.autocrlf” to false, preferring to keep this configuration in .gitattributes; 
* we obviously don’t want binary files to be touched by eol-normalization; 
* we also don’t want to declare all possible patterns of binary files - Git is good enough in detecting them automatically.

However, I’ve found no way to do so.

If I declare `* eol=lf` in .gitattributes, it makes Git treat all files as text and thus convert CRLF to LF even in binary files. It is consistent with man, but a bit surprising to have e.g. a zip or png file modified in this way.

One could expect `* text=auto eol=lf` to work the way we want, but unfortunately it doesn’t work either: “eol=lf” forces “text” on all files.

Thanks a lot for your help!
-- Kirill.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to have EOL=LF and keep binary files auto-detection?
  2016-04-25 14:11 How to have EOL=LF and keep binary files auto-detection? Kirill Likhodedov
@ 2016-04-25 16:46 ` Torsten Bögershausen
  2016-04-26 15:31   ` Nikolay Chashnikov
  0 siblings, 1 reply; 3+ messages in thread
From: Torsten Bögershausen @ 2016-04-25 16:46 UTC (permalink / raw)
  To: Kirill Likhodedov, git
  Cc: Николай Чашников

On 25.04.16 16:11, Kirill Likhodedov wrote:
> Hi, 
> 
> I wonder if it is possible both to have LFs in all and only text files in working trees, and keep Git’s binary files auto-detection?
> 
> To be more precise:
> * we want all text files to be checked out in LF; 
> * we don’t want force people to set “core.autocrlf” to false, preferring to keep this configuration in .gitattributes; 
> * we obviously don’t want binary files to be touched by eol-normalization; 
> * we also don’t want to declare all possible patterns of binary files - Git is good enough in detecting them automatically.
> 
> However, I’ve found no way to do so.
> 
> If I declare `* eol=lf` in .gitattributes, it makes Git treat all files as text and thus convert CRLF to LF even in binary files. It is consistent with man, but a bit surprising to have e.g. a zip or png file modified in this way.
> 
> One could expect `* text=auto eol=lf` to work the way we want, but unfortunately it doesn’t work either: “eol=lf” forces “text” on all files.
> 
> Thanks a lot for your help!
> -- Kirill.

The short answer: Git doesn't currently do that.
The closest you can get, is to use
echo "* text=auto" >.gitattributes
and
git config core.eol lf
git config core.autocrlf false.

The longer answer is, that I am working on a patch to allow just
the combination of "* text=auto eol=lf" to work as you want it.

Which platform do you use ?
And (out of curiosity, why do you want text files with LF ?)

If you are willing to compile and install Git yourself,
you can use the branch here:
https://github.com/tboegi/git/commits/160421_0706_reliable_t0027_allow_TC_combined_ident_CRLF_v7

Feedback is welcome, if it works as expected.

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: How to have EOL=LF and keep binary files auto-detection?
  2016-04-25 16:46 ` Torsten Bögershausen
@ 2016-04-26 15:31   ` Nikolay Chashnikov
  0 siblings, 0 replies; 3+ messages in thread
From: Nikolay Chashnikov @ 2016-04-26 15:31 UTC (permalink / raw)
  To: Torsten Bögershausen; +Cc: Kirill Likhodedov, git

Thank you for the information.

We create products (IDEs for different programming languages) for the
three major platforms (Window/Linux/Mac OSX). Our products are written
in Java and we want to minimize differences between distributions for
different platforms, so we use LF separators for all resource files.

On Mon, Apr 25, 2016 at 7:46 PM, Torsten Bögershausen <tboegi@web.de> wrote:
> On 25.04.16 16:11, Kirill Likhodedov wrote:
>> Hi,
>>
>> I wonder if it is possible both to have LFs in all and only text files in working trees, and keep Git’s binary files auto-detection?
>>
>> To be more precise:
>> * we want all text files to be checked out in LF;
>> * we don’t want force people to set “core.autocrlf” to false, preferring to keep this configuration in .gitattributes;
>> * we obviously don’t want binary files to be touched by eol-normalization;
>> * we also don’t want to declare all possible patterns of binary files - Git is good enough in detecting them automatically.
>>
>> However, I’ve found no way to do so.
>>
>> If I declare `* eol=lf` in .gitattributes, it makes Git treat all files as text and thus convert CRLF to LF even in binary files. It is consistent with man, but a bit surprising to have e.g. a zip or png file modified in this way.
>>
>> One could expect `* text=auto eol=lf` to work the way we want, but unfortunately it doesn’t work either: “eol=lf” forces “text” on all files.
>>
>> Thanks a lot for your help!
>> -- Kirill.
>
> The short answer: Git doesn't currently do that.
> The closest you can get, is to use
> echo "* text=auto" >.gitattributes
> and
> git config core.eol lf
> git config core.autocrlf false.
>
> The longer answer is, that I am working on a patch to allow just
> the combination of "* text=auto eol=lf" to work as you want it.
>
> Which platform do you use ?
> And (out of curiosity, why do you want text files with LF ?)
>
> If you are willing to compile and install Git yourself,
> you can use the branch here:
> https://github.com/tboegi/git/commits/160421_0706_reliable_t0027_allow_TC_combined_ident_CRLF_v7
>
> Feedback is welcome, if it works as expected.
>
>
>
>



-- 
Nikolay Chashnikov
JetBrains
http://www.jetbrains.com
The Drive to Develop

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-04-26 15:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-25 14:11 How to have EOL=LF and keep binary files auto-detection? Kirill Likhodedov
2016-04-25 16:46 ` Torsten Bögershausen
2016-04-26 15:31   ` Nikolay Chashnikov

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).