# Per file configurable eol-style transformations with Git?

4 messages from 2009-11-21 to 2009-11-22. Participants: Alexander Veit, Jakub Narebski, Junio C Hamano.
Thread: https://gitlist.dev/t/21697

## Alexander Veit, 2009-11-21 20:21

Subject: Per file configurable eol-style transformations with Git?
Message-ID: <9ED0EB52C33C41209726C6F4DB7FC194@helium>
URL: https://gitlist.dev/e/9ED0EB52C33C41209726C6F4DB7FC194%40helium

```
Hi,

we have projects that contain text files that need to
have different end-of-line sequences, depending on the
type of file, and depending on the operating system where
they are checked out.

There are files that have

 - LF line breaks on each platform,
 - CR LF line breaks on each platform, or
 - either LF or CR LF line breaks, depending on the
   platform's native end-of-line style.

With Subversion, the correct behaviour in checkouts, commits,
diffs, or merges can easily be achieved by setting the appropriate
svn:eol-style [*].

As I understand the Git documentation there's no such concept as a
repository end-of-line style, or as an end-of-line transformation
between repository and working copy.

So I wonder if it is possible to mimic Subversion's end-of-line handling
with Git, especially for the svn:eol-style=native.

-- 
Regards,
Alex


[*]
http://svnbook.red-bean.com/nightly/de/svn-book.html#svn.advanced.props.special.eol-style

```

## Jakub Narebski, 2009-11-21 21:18

Subject: Re: Per file configurable eol-style transformations with Git?
Message-ID: <m3tywnbmpj.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m3tywnbmpj.fsf%40localhost.localdomain
In-Reply-To: <9ED0EB52C33C41209726C6F4DB7FC194@helium>

```
"Alexander Veit" <alexander.veit@gmx.net> writes:

> we have projects that contain text files that need to
> have different end-of-line sequences, depending on the
> type of file, and depending on the operating system where
> they are checked out.
> 
> There are files that have
> 
>  - LF line breaks on each platform,
>  - CR LF line breaks on each platform, or
>  - either LF or CR LF line breaks, depending on the
>    platform's native end-of-line style.
> 
> With Subversion, the correct behaviour in checkouts, commits,
> diffs, or merges can easily be achieved by setting the appropriate
> svn:eol-style [*].
> 
> As I understand the Git documentation there's no such concept as a
> repository end-of-line style, or as an end-of-line transformation
> between repository and working copy.
> 
> So I wonder if it is possible to mimic Subversion's end-of-line handling
> with Git, especially for the svn:eol-style=native.

See `crlf` attribute, which can be set, unset, unspecified, set to
"input", and used together with core.autocrlf ("true", "false", "input")
and core.safecrlf.  Attributes can be set per path (using globbing
patterns) in .gitattributes file in tree, or in .git/info/attributes
(per repository).

HTH
-- 
Jakub Narebski
Poland
ShadeHawk on #git

```

## Alexander Veit, 2009-11-21 23:49

Subject: Re: Per file configurable eol-style transformations with Git?
Message-ID: <1050CAACABF64864A0CF79C957BF773B@helium>
URL: https://gitlist.dev/e/1050CAACABF64864A0CF79C957BF773B%40helium
In-Reply-To: <m3tywnbmpj.fsf@localhost.localdomain>

```
Jakub Narebski wrote:

> See `crlf` attribute, which can be set, unset, unspecified, set
> to "input", and used together with core.autocrlf ("true", "false",
> "input") and core.safecrlf.  Attributes can be set per path (using
> globbing patterns) in .gitattributes file in tree, or in
> .git/info/attributes (per repository).

I've already tried 

[core]
  autoCRLF = true

in the global gitconfig under Windows. After git clone an immediate
git diff shows every line changed in certain files:

diff --git a/c_crlf_text.txt b/c_crlf_text.txt
index 3b0a76f..3473745 100644
--- a/c_crlf_text.txt
+++ b/c_crlf_text.txt
@@ -1,5 +1,5 @@
-z1
-z2
-z3
-z4
-
+z1
+z2
+z3
+z4
+

file * on Windows:
c___lf_text.txt;  ASCII text, with CRLF line terminators
c_crlf_text.txt;  ASCII text, with CRLF line terminators


file * on Linux
c_crlf_text.txt:  ASCII text, with CRLF line terminators
c___lf_text.txt:  ASCII text

I don't know if this behaviour is supposed to be correct,
but to me it seems to be wrong.

git version 1.6.5.1.1367.gcd48

-- 
Cheers,
Alex

```

## Junio C Hamano, 2009-11-22 01:24

Subject: Re: Per file configurable eol-style transformations with Git?
Message-ID: <7v6393nyg9.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v6393nyg9.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1050CAACABF64864A0CF79C957BF773B@helium>

```
"Alexander Veit" <alexander.veit@gmx.net> writes:

> Jakub Narebski wrote:
>
>> See `crlf` attribute, which can be set, unset, unspecified, set
>> to "input", and used together with core.autocrlf ("true", "false",
>> "input") and core.safecrlf.  Attributes can be set per path (using
>> globbing patterns) in .gitattributes file in tree, or in
>> .git/info/attributes (per repository).
>
> I've already tried 
>
> [core]
>   autoCRLF = true
>
> in the global gitconfig under Windows.

That would not be per-file anyway.

What Jakub suggested makes sense.  You want to read up on
gitattributes(5).

```
