git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Torsten Bögershausen" <tboegi@web.de>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Lars Schneider <larsxschneider@gmail.com>,
	git <git@vger.kernel.org>, Jeff King <peff@peff.net>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: Re: Consequences of CRLF in index?
Date: Tue, 24 Oct 2017 21:02:34 +0200	[thread overview]
Message-ID: <20171024190234.GA21077@tor.lan> (raw)
In-Reply-To: <20171024181415.3tvmc36aqi335v66@aiede.mtv.corp.google.com>

On Tue, Oct 24, 2017 at 11:14:15AM -0700, Jonathan Nieder wrote:
> Hi,
> 
> Lars Schneider wrote:
> 
> > I've migrated a large repo (110k+ files) with a lot of history (177k commits)
> > and a lot of users (200+) to Git. Unfortunately, all text files in the index
> > of the repo have CRLF line endings. In general this seems not to be a problem
> > as the project is developed exclusively on Windows.
> 
> Sounds good.
> 
> > However, I wonder if there are any "hidden consequences" of this setup?
> > If there are consequences, then I see two options. Either I rebase the repo
> > and fix the line endings for all commits or I add a single commit that fixes
> > the line endings for all files. Both actions require coordination with the
> > users to avoid repo trouble/merge conflicts. The "single fixup commit" options
> > would also make diffs into the past look bad. Would a single large commit have
> > any impact on the performance of standard Git operations?
> 
> There are no hidden consequences that I'm aware of.  If you later
> decide that you want to become a cross-platform project, then you may
> want to switch to LF endings, in which case I suggest the "single
> fixup commit" strategy.
> 
> In any event, you also probably want to declare what you're doing
> using .gitattributes.  By checking in the files as CRLF, you are
> declaring that you do *not* want Git to treat them as text files
> (i.e., you do not want Git to change the line endings), so something
> as simple as
> 
> 	* -text
> 
> should do the trick.  See gitattributes(5) for details.

Exactly.
The "hidden consequence" may be the other way around:
If you don't specify .gitattributes, then all people who have core.autocrlf=true
will suffer from a runtime penalty.
core.autocrlf=true means "auto".
At each checkout Git needs to figure out that the file has CRLF in the repo,
so that there is no conversion done.
The same happens on "git add" or "git commit" (and sometimes on "git status").

The penalty may be low, but Dscho once reported that it is measurable & painful
on a "big repo".

The other advantage of "* -text" in .gitattributes is that new files are handled
consistantly accross developers.

Those who have "core.autocrlf=false" would produce commits with CRLF for new
files, and those developpers who have core.autocrlf=true would produce files
with LF in the index and CRLF in the worktree.
This may (most probably will) cause confusion later, when things are pushed and
pulled.

> 
> I'd be interested to hear what happens when diff-ing across a line
> ending fixup commit.  Is this an area where Git needs some
> improvement?  "git merge" knows an -Xrenormalize option to deal with a
> related problem --- it's possible that "git diff" needs to learn a
> similar trick.

That is a tricky thing.
Sometimes you want to see the CLRF - LF as a diff, (represented as "^M"),
and sometimes not.

All in all "* -text" is a good choice for Windows-only projects.

> 
> Thanks and hope that helps,
> Jonathan

  reply	other threads:[~2017-10-24 19:02 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-24 17:48 Consequences of CRLF in index? Lars Schneider
2017-10-24 18:14 ` Jonathan Nieder
2017-10-24 19:02   ` Torsten Bögershausen [this message]
2017-10-25 12:13     ` Johannes Schindelin
2017-10-25  1:51   ` Junio C Hamano
2017-10-25  4:53     ` Junio C Hamano
2017-10-25 16:44       ` Stefan Beller
2017-10-26  5:54         ` Junio C Hamano
2017-10-27  6:13           ` Re* " Junio C Hamano
2017-10-27 17:06             ` Stefan Beller
2017-10-27 17:07             ` [PATCH 0/2] " Stefan Beller
2017-10-27 17:07               ` [PATCH 1/2] xdiff/xdiff.h: remove unused flags Stefan Beller
2017-10-27 17:07               ` [PATCH 2/2] xdiff/xdiffi.c: remove unneeded function declarations Stefan Beller
2017-10-30 17:20               ` [PATCH 0/2] Re* Consequences of CRLF in index? Stefan Beller
2017-10-31  2:44                 ` Junio C Hamano
2017-10-31 16:41                   ` Stefan Beller
2017-10-31 17:01                     ` Jeff King
2017-11-07  6:40       ` [PATCH v2 0/2] Teach "diff" to ignore only CR at EOL Junio C Hamano
2017-11-07  6:40         ` [PATCH v2 1/2] xdiff: reassign xpparm_t.flags bits Junio C Hamano
2017-11-07 12:44           ` Johannes Schindelin
2017-11-07 15:02             ` Junio C Hamano
2017-11-07  6:40         ` [PATCH v2 2/2] diff: --ignore-cr-at-eol Junio C Hamano
2017-11-07 13:23           ` Johannes Schindelin
2017-11-08  0:43             ` Junio C Hamano
2017-11-08  0:49               ` Junio C Hamano
2017-11-15  4:28             ` Junio C Hamano
2017-11-07 12:30         ` [PATCH v2 0/2] Teach "diff" to ignore only CR at EOL Johannes Schindelin
2017-11-07 15:12           ` Junio C Hamano
2017-11-07 17:42             ` Stefan Beller
2017-10-25 17:04   ` Consequences of CRLF in index? Lars Schneider
2017-10-25 17:13     ` Jonathan Nieder
2017-10-26 11:06       ` Lars Schneider
2017-10-26 19:15       ` Torsten Bögershausen
2017-10-24 21:04 ` Johannes Sixt
2017-10-25 12:19   ` Johannes Schindelin
2017-10-26  7:09     ` Johannes Sixt
2017-10-26 11:01       ` Lars Schneider
2017-10-26 19:22         ` Torsten Bögershausen
2017-10-26 20:20         ` Johannes Sixt
2017-10-26 20:30           ` Jonathan Nieder
2017-10-26 20:51             ` Johannes Sixt
2017-10-26 22:27               ` Ross Kabus
2017-10-27  1:05                 ` Junio C Hamano
2017-10-27 15:18         ` Johannes Schindelin

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=20171024190234.GA21077@tor.lan \
    --to=tboegi@web.de \
    --cc=git@vger.kernel.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=jrnieder@gmail.com \
    --cc=larsxschneider@gmail.com \
    --cc=peff@peff.net \
    /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).