git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Issues with line-endings and autocrlf setting after SVN to Git  transition
@ 2010-07-02 19:59 Bradley Wagner
  2010-07-03 20:09 ` Eyvind Bernhardsen
  0 siblings, 1 reply; 2+ messages in thread
From: Bradley Wagner @ 2010-07-02 19:59 UTC (permalink / raw
  To: git

So I'm running into the infamous issue with line-endings after
migrating an SVN repo to Git.

I'm on OS X and I currently have auto.crlf set to "input" as
recommended on this GitHub page:
http://help.github.com/dealing-with-lineendings/. I'm doing a fresh
clone of our repo and it's showing many files as having changed.

I've gotten conflicting answers to my question on Stack Overflow:
http://stackoverflow.com/questions/3161797/will-the-fix-to-correct-line-endings-in-git-repositories-make-future-diffs-usel.
Should I fix this with a commit or turn off autocrlf? I intend to use
this repo in both OS X and Windows environments. The problem with
fixing it with a commit is that the commit will change every single
line of these affected files. As I understand it from SVN, this means
that any diffs that span that commit will basically show the entire
files as being changed which is definitely frustrating.

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

* Re: Issues with line-endings and autocrlf setting after SVN to Git  transition
  2010-07-02 19:59 Issues with line-endings and autocrlf setting after SVN to Git transition Bradley Wagner
@ 2010-07-03 20:09 ` Eyvind Bernhardsen
  0 siblings, 0 replies; 2+ messages in thread
From: Eyvind Bernhardsen @ 2010-07-03 20:09 UTC (permalink / raw
  To: Bradley Wagner; +Cc: git

On 2. juli 2010, at 21.59, Bradley Wagner wrote:

> So I'm running into the infamous issue with line-endings after
> migrating an SVN repo to Git.
> 
> I'm on OS X and I currently have auto.crlf set to "input" as
> recommended on this GitHub page:
> http://help.github.com/dealing-with-lineendings/. I'm doing a fresh
> clone of our repo and it's showing many files as having changed.

That GitHub page is noble, but wrong: setting core.autocrlf gets you into trouble when you clone a repository that already has CRLFs, as you have found.

The upcoming 1.7.2 version of git adds a safety feature to autocrlf that makes it ignore files that already have CRLF in the repository.  You will be able to use autocrlf without getting the spurious changes, but it will no longer convert files with "wrong" line endings already in the repository.

> I've gotten conflicting answers to my question on Stack Overflow:
> http://stackoverflow.com/questions/3161797/will-the-fix-to-correct-line-endings-in-git-repositories-make-future-diffs-usel.
> Should I fix this with a commit or turn off autocrlf? I intend to use
> this repo in both OS X and Windows environments.

It depends what you want, but right now I suggest turning autocrlf off and living with the mixed line endings.  Once git 1.7.2 is released you can start using autocrlf to get CRLF on Windows, as long as you don't mind the mix of LF and CRLF files on OS X.

> The problem with
> fixing it with a commit is that the commit will change every single
> line of these affected files. As I understand it from SVN, this means
> that any diffs that span that commit will basically show the entire
> files as being changed which is definitely frustrating.

"Diff" and "blame" can be told to ignore changes in whitespace, but the real problem with doing a conversion like this using (old) autocrlf is that checking out versions from before the conversion will still show lots of changes.

This is where the other normalization feature introduced in 1.7.2 comes in.  Marking a file with the "text" attribute tells git to normalize its line endings, and the attribute can be set to "auto" for all files if you want automatic conversion.  A configuration variable lets you set which line endings you want in your working directory.  Older versions are not affected since it is an attribute, so you won't get spurious changes when you check them out.

So if you want to normalize line endings in your repository, wait for git 1.7.2 and then read up on the "text" attribute.
-- 
Eyvind

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

end of thread, other threads:[~2010-07-03 20:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-07-02 19:59 Issues with line-endings and autocrlf setting after SVN to Git transition Bradley Wagner
2010-07-03 20:09 ` Eyvind Bernhardsen

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