# Dealing with mac linefeeds in git repository

3 messages from 2010-03-31 to 2010-04-01. Participants: jussi.sirpoma@sks.fi, Ilari Liusvaara.
Thread: https://gitlist.dev/t/23270

## jussi.sirpoma@sks.fi, 2010-03-31 13:07

Subject: Dealing with mac linefeeds in git repository
Message-ID: <OF7E748769.D4E7BC90-ONC22576F7.00483B3D-C22576F7.00484D0A@sks.fi>
URL: https://gitlist.dev/e/OF7E748769.D4E7BC90-ONC22576F7.00483B3D-C22576F7.00484D0A%40sks.fi

```
I am running cygwin git version 1.6.4.2.

Some of the source code for our projects is encoded in mac linefeeds due 
to proprietary
software platform. My current solution is to flag those files tu use no 
linefeed conversion and
to use separate diff program by having this in .gitattributes:

*.BA -crlf diff=winmerge

I also have these crlf settings enabled:

core.autocrlf=true
core.safecrlf=true

This solution works, but is not optimal as git cannot follow the changed 
lines, produce
annotations or diffs. Now I am wondering if I could make git work with a 
little different 
configuration:

* The *.BA files with mac linefeeds would be stored with normal linux 
linefeeds
* The files would be converted on checkout to mac linefeeds the same way 
as core.autcrlf works

Is this doable or even a good approach?

- Jussi Sirpoma

```

## Ilari Liusvaara, 2010-03-31 14:16

Subject: Re: Dealing with mac linefeeds in git repository
Message-ID: <20100331141608.GA2542@LK-Perkele-V2.elisa-laajakaista.fi>
URL: https://gitlist.dev/e/20100331141608.GA2542%40LK-Perkele-V2.elisa-laajakaista.fi
In-Reply-To: <OF7E748769.D4E7BC90-ONC22576F7.00483B3D-C22576F7.00484D0A@sks.fi>

```
On Wed, Mar 31, 2010 at 04:07:40PM +0300, jussi.sirpoma@sks.fi wrote:
> I am running cygwin git version 1.6.4.2.
> 
> Some of the source code for our projects is encoded in mac linefeeds due 
> to proprietary
> software platform. My current solution is to flag those files tu use no 
> linefeed conversion and
> to use separate diff program by having this in .gitattributes:

> annotations or diffs. Now I am wondering if I could make git work with a 
> little different 
> configuration:
> 
> * The *.BA files with mac linefeeds would be stored with normal linux 
> linefeeds
> * The files would be converted on checkout to mac linefeeds the same way 
> as core.autcrlf works
> 
> Is this doable or even a good approach?
 
AFAIK, its doable. One can specify filter programs to be executed when
checking out / adding files. That program could do CR <-> LF translation.

See filter attribute in man gitattributes.

-Ilari

```

## jussi.sirpoma@sks.fi, 2010-04-01 13:19

Subject: Re: Dealing with mac linefeeds in git repository
Message-ID: <OF04EBFCA7.AEB239AD-ONC22576F8.003BC70A-C22576F8.0049585D@sks.fi>
URL: https://gitlist.dev/e/OF04EBFCA7.AEB239AD-ONC22576F8.003BC70A-C22576F8.0049585D%40sks.fi
In-Reply-To: <20100331141608.GA2542@LK-Perkele-V2.elisa-laajakaista.fi>

```
Thank you Ilari,

The filter approach seems to work nicely.

git config --global filter.maclinefeed.smudge 'tr \\n \\r'
git config --global filter.maclinefeed.clean 'tr \\r \\n'

With suitable filter and -crlf settings in .gitattributes,

- Jussi Sirpoma



From:
Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
To:
jussi.sirpoma@sks.fi
Cc:
git@vger.kernel.org
Date:
31.03.2010 17:14
Subject:
Re: Dealing with mac linefeeds in git repository
Sent by:
git-owner@vger.kernel.org



On Wed, Mar 31, 2010 at 04:07:40PM +0300, jussi.sirpoma@sks.fi wrote:
> I am running cygwin git version 1.6.4.2.
> 
> Some of the source code for our projects is encoded in mac linefeeds due 

> to proprietary
> software platform. My current solution is to flag those files tu use no 
> linefeed conversion and
> to use separate diff program by having this in .gitattributes:

> annotations or diffs. Now I am wondering if I could make git work with a 

> little different 
> configuration:
> 
> * The *.BA files with mac linefeeds would be stored with normal linux 
> linefeeds
> * The files would be converted on checkout to mac linefeeds the same way 

> as core.autcrlf works
> 
> Is this doable or even a good approach?
 
AFAIK, its doable. One can specify filter programs to be executed when
checking out / adding files. That program could do CR <-> LF translation.

See filter attribute in man gitattributes.

-Ilari

```
