git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Jens Bauer <jens-lists@gpio.dk>
Cc: Drew Northup <drew.northup@maine.edu>, git@vger.kernel.org
Subject: Re: CRLF, LF ... CR ?
Date: Thu, 13 Sep 2012 14:23:44 -0400	[thread overview]
Message-ID: <20120913182344.GA2181@sigill.intra.peff.net> (raw)
In-Reply-To: <20120913201720399747.156466ee@gpio.dk>

On Thu, Sep 13, 2012 at 08:17:20PM +0200, Jens Bauer wrote:

> In my home directory, I have a .gitconfig file, here's the interesting part:
> [core]
>         editor = nano
>         excludesfile = /Users/jens/.gitexcludes
>         attributesfile = /Users/jens/.gitattributes
> 
> [filter "cr"]
>         clean = tr '\\r' '\\n'
>         smudge = tr '\\n' '\\r'
> 
> 
> In my home directory I added .gitattributes:
> *.osm   filter=cr

Looks right.

> Now, when I clone the project, make a change and then issue this command...
> $ git diff mypcb.osm
> 
> ...I get a strange diff. On line 3, one of the files shows a lot of control-m (<cr>) lines.
> After that, I see <lf> lines, all prefixed with a '+', as if they were added.
> 
> I think I might be nearly there, just missing some obvious detail somewhere.

Yes, that's expected.  The point of the "clean" filter is to convert
your working tree file into a canonical (lf-only) representation inside
the repository. But you've already made commits with the cr form in the
repository. So you can choose one of:

  1. Make a new commit with these settings, which will have the
     canonical format. Accept that the old history will be funny, but
     you will be OK from here on out.

  2. Rewrite the old history to pretend that it was always LF. This
     gives you a nice clean history, but if you are collaborating with
     other people, they will need to rebase their work on the new
     history. See "git help filter-branch" for details.

-Peff

  reply	other threads:[~2012-09-13 18:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13 15:09 CRLF, LF ... CR ? Jens Bauer
2012-09-13 15:34 ` Drew Northup
2012-09-13 15:43   ` Jeff King
2012-09-13 15:53     ` Jens Bauer
2012-09-13 18:17       ` Jens Bauer
2012-09-13 18:23         ` Jeff King [this message]
2012-09-13 18:55           ` Jens Bauer
2012-09-13 18:34       ` Johannes Sixt
2012-09-13 19:13         ` Jens Bauer
2012-09-13 15:43   ` Erik Faye-Lund
2012-09-14  4:06 ` David Aguilar
2012-09-14  4:36   ` Jens Bauer
2012-09-14  4:51   ` Junio C Hamano
2012-09-26  8:42     ` David Aguilar
2012-09-26 10:12       ` Jens Bauer
2012-09-26 10:31         ` Jens Bauer
2012-09-27  6:16       ` Junio C Hamano
2012-09-27 13:42         ` Jens Bauer

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=20120913182344.GA2181@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=drew.northup@maine.edu \
    --cc=git@vger.kernel.org \
    --cc=jens-lists@gpio.dk \
    /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 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 NNTP newsgroup(s).