git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
To: "git@vger.kernel.org List" <git@vger.kernel.org>
Cc: Dmitry Potapov <dpotapov@gmail.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	mat <matthieu.stigler@gmail.com>,
	hasen j <hasan.aljudy@gmail.com>,
	Erik Faye-Lund <kusmabite@googlemail.com>,
	Junio C Hamano <gitster@pobox.com>,
	Avery Pennarun <apenwarr@gmail.com>,
	Robert Buck <buck.robert.j@gmail.com>,
	Finn Arne Gangstad <finnag@pvv.org>
Subject: Re: [PATCH/RFC v2 1/4] Add "core.eolStyle" variable to control end-of-line conversion
Date: Sun, 9 May 2010 12:42:17 +0200	[thread overview]
Message-ID: <CD080D38-811C-4BBF-A5CB-6B613555FE72@gmail.com> (raw)
In-Reply-To: <20100509070043.GB14069@dpotapov.dyndns.org>

I guess I should nail my flag to the mast: Here's what I would have done, with the benefit of plenty of hindsight, had we not had core.autocrlf, and also what I think we should do to approach that ideal.

Please don't get hung up too much on the names, they were chosen to not match anything suggested so far so that I can refer back to them unambiguously.

My user interface would have been:

- an attribute "eolconv" that enables or disables line ending conversion
- a config variable "core.eolconv" that sets "eolconv" for all files where it is unset
- a config variable "core.localeol" that decides whether LF or CRLF is preferred

This provides the means to enable normalization on a per-project ("eolconv") or per-repository ("core.eolconv") basis, and allows the user to override the platform native line ending when normalization is in effect.


Now, how does that compare to Git's current implementation of autocrlf?

- The config variable "core.autocrlf" enables or disables line ending conversion and decides if conversion occurs in "both" directions ("autocrlf=true") or just towards the repository ("autocrlf=input").

- The attribute "crlf" allows the automatic detection of binary files to be overridden, and forcing one-way conversion even if "core.autocrlf" is true ("crlf=input").  It only has an effect when "core.autocrlf" is enabled.

I think I've stated my case against these settings before, but just to be clear, I think the biggest problem is that there's no way to tell if a repository is normalized from the contents of the repository, and it's not safe to enable autocrlf if the repository isn't normalized.

The second biggest problem is that "true" and "input" are bad names for "normalize and put CRLFs in my working directory" and "normalize and put LFs in my working directory", respectively.


So how to progress from here?

As Junio observed, the "crlf" attribute can act just like my hypothetical "eolconv" if you squeeze its semantics a bit and add a new setting.  Disregarding "crlf=input" makes it exactly equivalent to "eolconv".  The name is a bit off, but it's not monstrous.

"core.localeol" has no equivalent in the current implementation.  Using "core.autocrlf" as a stand in would not work, since that setting is expected to actually enable normalization, so if we want a moral equivalent of "eolconv", we need a new setting.  "core.crlf" has been suggested to match the "crlf" attribute, but that causes confusion: why doesn't setting "core.crlf=auto" mean the same thing as setting "crlf=auto" on all files?  I think a new variable is needed.

"core.autocrlf" is problematic because it mixes up two things: you use it to turn on normalization _and_ to decide which line endings you prefer, and to maintain backwards compatibility its semantics can't be changed too much.  A new setting "core.autocrlf=auto" (meaning the same as "eolconv=auto" on all files where "eolconv" isn't explicitly set) is a possibility, if kind of ugly.  Another alternative is to make "core.autocrlf=true" respect "core.localeol", but that would be a v1.8.0 kind of change.


My current thinking on how to change my series now runs along these lines:

- keep the current "crlf=auto" change
- rename "core.eolStyle" to "core.localcrlf"
- add a "core.crlf" that sets the "crlf" attribute on paths where it isn't explicitly configured
- keep "core.autocrlf" for backwards compatibility, but make "core.autocrlf=input" and "core.autocrlf=true" complain if they are in conflict with the other config settings.



An apology: I know I've said a lot of nasty things about autocrlf, but I haven't had to touch a thing about its implementation, which works very well.  My only beef is with its user interface (which probably made sense when it was implemented); the reason I don't think I'm just whining about the colour of the bike shed is that a lot of other people trip over that interface, to the point where the standard recommendation is simply to disable the feature, and I'd like to make it both more functional and more understandable.

In short, I'm burning autocrlf to save it :)
-- 
Eyvind

  parent reply	other threads:[~2010-05-09 10:44 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-08 21:46 [PATCH/RFC v2 0/4] End-of-line normalization, take 2 (now only slightly scary) Eyvind Bernhardsen
2010-05-08 21:46 ` [PATCH/RFC v2 1/4] Add "core.eolStyle" variable to control end-of-line conversion Eyvind Bernhardsen
2010-05-08 21:57   ` Linus Torvalds
2010-05-08 22:17     ` Eyvind Bernhardsen
2010-05-08 22:53       ` Eyvind Bernhardsen
2010-05-08 23:08         ` Linus Torvalds
2010-05-09  8:13           ` Eyvind Bernhardsen
2010-05-09 18:11             ` Linus Torvalds
2010-05-09 20:11               ` Eyvind Bernhardsen
2010-05-09  7:00         ` Dmitry Potapov
2010-05-09  7:30           ` hasen j
2010-05-10  7:16             ` Dmitry Potapov
2010-05-09  8:34           ` Eyvind Bernhardsen
2010-05-09 10:42           ` Eyvind Bernhardsen [this message]
2010-05-09 11:14             ` Robert Buck
2010-05-09 18:59               ` Eyvind Bernhardsen
2010-05-09 20:46                 ` Robert Buck
2010-05-10  4:33                   ` Eyvind Bernhardsen
2010-05-10 11:43                     ` Robert Buck
2010-05-10 13:25                       ` Robert Buck
2010-05-10 14:03                         ` Dmitry Potapov
2010-05-09 17:02             ` Jay Soffian
2010-05-09 17:43               ` Jay Soffian
2010-05-10 18:33               ` Eyvind Bernhardsen
2010-05-09 17:45             ` Junio C Hamano
2010-05-09 18:18               ` Finn Arne Gangstad
2010-05-09 21:57                 ` Junio C Hamano
2010-05-10  5:14                   ` Eyvind Bernhardsen
2010-05-09 20:25               ` Eyvind Bernhardsen
2010-05-09 20:09             ` Finn Arne Gangstad
2010-05-10  8:13               ` Dmitry Potapov
2010-05-10 11:14                 ` Finn Arne Gangstad
2010-05-10 13:46                   ` Dmitry Potapov
2010-05-09  9:21         ` Finn Arne Gangstad
2010-05-08 21:46 ` [PATCH/RFC v2 2/4] Add tests for per-repository eol normalization Eyvind Bernhardsen
2010-05-08 21:46 ` [PATCH/RFC v2 3/4] Pass eol conv mode as an argument instead of using global auto_crlf Eyvind Bernhardsen
2010-05-08 21:46 ` [PATCH/RFC v2 4/4] Add per-repository eol normalization Eyvind Bernhardsen

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=CD080D38-811C-4BBF-A5CB-6B613555FE72@gmail.com \
    --to=eyvind.bernhardsen@gmail.com \
    --cc=apenwarr@gmail.com \
    --cc=buck.robert.j@gmail.com \
    --cc=dpotapov@gmail.com \
    --cc=finnag@pvv.org \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=hasan.aljudy@gmail.com \
    --cc=kusmabite@googlemail.com \
    --cc=matthieu.stigler@gmail.com \
    --cc=torvalds@linux-foundation.org \
    /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).