From: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
To: git@vger.kernel.org
Cc: msysGit <msysgit@googlegroups.com>,
Linus Torvalds <torvalds@linux-foundation.org>,
Junio C Hamano <gitster@pobox.com>,
Dmitry Potapov <dpotapov@gmail.com>,
Robert Buck <buck.robert.j@gmail.com>,
Finn Arne Gangstad <finnag@pvv.org>,
Jay Soffian <jaysoffian@gmail.com>
Subject: [RFC/PATCH v3 5/5] Rename "core.autocrlf" config variable as "core.eolconv"
Date: Thu, 13 May 2010 01:00:55 +0200 [thread overview]
Message-ID: <d739aefee3d015b739b41e1db549c19472c3dd5a.1273700831.git.eyvind.bernhardsen@gmail.com> (raw)
In-Reply-To: <cover.1273700831.git.eyvind.bernhardsen@gmail.com>
As asserted by myself and not vigourously contested on the list,
"autocrlf" is a pretty bad name. Rename the variable "core.eolconv",
but also accept "core.autocrlf" for backwards compatibility.
Also add aliases "crlf" for "true" and "lf" for "input".
Signed-off-by: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
---
Documentation/config.txt | 22 ++++++++-------
Documentation/gitattributes.txt | 16 ++++++------
config.c | 11 ++++++--
t/t0020-crlf.sh | 54 +++++++++++++++++++++++++++++++++++++++
4 files changed, 82 insertions(+), 21 deletions(-)
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 4d3c472..6814e23 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -196,16 +196,18 @@ core.quotepath::
quoted without `-z` regardless of the setting of this
variable.
-core.autocrlf::
- If true, makes git convert `CRLF` at the end of lines in text files to
+core.eolconv::
+ If true or 'crlf', makes git convert `CRLF` at the end of lines in text files to
`LF` when reading from the work tree, and convert in reverse when
writing to the work tree. The variable can be set to
- 'input', in which case the conversion happens only while
+ 'input' or 'lf', in which case the conversion happens only while
reading from the work tree but files are written out to the work
tree with `LF` at the end of lines. A file is considered
- "text" (i.e. be subjected to the autocrlf mechanism) based on
+ "text" (i.e. subject to the eolconv mechanism) based on
the file's `crlf` attribute, or if `crlf` is unspecified,
based on the file's contents. See linkgit:gitattributes[5].
+ For backwards compatibility, `core.autocrlf` is an alias of
+ this variable.
core.safecrlf::
If true, makes git check if converting `CRLF` is reversible when
@@ -214,12 +216,12 @@ core.safecrlf::
For example, committing a file followed by checking out the
same file should yield the original file in the work tree. If
this is not the case for the current setting of
- `core.autocrlf`, git will reject the file. The variable can
+ `core.eolconv`, git will reject the file. The variable can
be set to "warn", in which case git will only warn about an
irreversible conversion but continue the operation.
+
CRLF conversion bears a slight chance of corrupting data.
-autocrlf=true will convert CRLF to LF during commit and LF to
+eolconv=true will convert CRLF to LF during commit and LF to
CRLF during checkout. A file that contains a mixture of LF and
CRLF before the commit cannot be recreated by git. For text
files this is the right thing to do: it corrects line endings
@@ -243,9 +245,9 @@ converting CRLFs corrupts data.
+
Note, this safety check does not mean that a checkout will generate a
file identical to the original file for a different setting of
-`core.autocrlf`, but only for the current one. For example, a text
-file with `LF` would be accepted with `core.autocrlf=input` and could
-later be checked out with `core.autocrlf=true`, in which case the
+`core.eolconv`, but only for the current one. For example, a text
+file with `LF` would be accepted with `core.eolconv=input` and could
+later be checked out with `core.eolconv=true`, in which case the
resulting file would contain `CRLF`, although the original file
contained `LF`. However, in both work trees the line endings would be
consistent, that is either all `LF` or all `CRLF`, but never mixed. A
@@ -991,7 +993,7 @@ gitcvs.allbinary::
as binary files, which suppresses any newline munging it
otherwise might do. Alternatively, if it is set to "guess",
then the contents of the file are examined to decide if
- it is binary, similar to 'core.autocrlf'.
+ it is binary, similar to 'core.eolconv'.
gitcvs.dbname::
Database used by git-cvsserver to cache revision information
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index 2887f85..7d02146 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -99,7 +99,7 @@ This attribute enables and controls end-of-line normalization. When a
text file is normalized, its line endings are converted to LF in the
repository. Text files can have their line endings converted to
CRLF in the working directory, using the `eolconv` attribute for
-individual files or the `core.autocrlf` configuration variable for all
+individual files or the `core.eolconv` configuration variable for all
files.
For compatibility with older versions of git, `crlf` is an alias for
@@ -126,19 +126,19 @@ Set to string value "crlf"::
This is similar to setting the attribute to `true`, but forces
git to convert line endings to CRLF when the file is checked
- out, regardless of `core.autocrlf`.
+ out, regardless of `core.eolconv`.
Set to string value "lf"::
This is similar to setting the attribute to `true`, but
prevents git from converting line endings to CRLF when the
- file is checked out, regardless of `core.autocrlf`. "input"
+ file is checked out, regardless of `core.eolconv`. "input"
is an alias for "lf".
Unspecified::
Leaving the `eolconv` attribute unspecified tells git to apply
- end-of-line normalization only if the `core.autocrlf`
+ end-of-line normalization only if the `core.eolconv`
configuration variable is set, the content appears to be text,
and the file is either new or already normalized in the
repository.
@@ -172,18 +172,18 @@ normalization in git.
If you simply want to have CRLF line endings in your working directory
regardless of the repository you are working in, you can set the
-config variable "core.autocrlf" without changing any attributes.
+config variable "core.eolconv" without changing any attributes.
------------------------
[core]
- autocrlf = true
+ eolconv = true
------------------------
This does not force normalization of all text files, but does ensure
that text files that you introduce to the repository have their line
endings normalized to LF when they are added, and that files that are
already normalized in the repository stay normalized. You can also
-set `autocrlf` to "input" to have automatic normalization of new text
+set `eolconv` to "input" to have automatic normalization of new text
files without conversion to CRLF in the working directory.
If you want to interoperate with a source code management system that
@@ -231,7 +231,7 @@ weirdchars.txt eolconv
If `core.safecrlf` is set to "true" or "warn", git verifies if
the conversion is reversible for the current setting of
-`core.autocrlf`. For "true", git rejects irreversible
+`core.eolconv`. For "true", git rejects irreversible
conversions; for "warn", git only prints a warning but accepts
an irreversible conversion. The safety triggers to prevent such
a conversion done to the files in the work tree, but there are a
diff --git a/config.c b/config.c
index b60a1ff..a5f445e 100644
--- a/config.c
+++ b/config.c
@@ -459,12 +459,17 @@ static int git_default_core_config(const char *var, const char *value)
return 0;
}
- if (!strcmp(var, "core.autocrlf")) {
- if (value && !strcasecmp(value, "input")) {
+ if (!strcmp(var, "core.eolconv") || !strcmp(var, "core.autocrlf")) {
+ if (value && (!strcasecmp(value, "input") ||
+ !strcasecmp(value, "lf"))) {
auto_crlf = AUTO_CRLF_INPUT;
return 0;
}
- auto_crlf = git_config_bool(var, value);
+ if (value && !strcasecmp(value, "crlf") ||
+ git_config_bool(var, value))
+ auto_crlf = AUTO_CRLF_TRUE;
+ else
+ auto_crlf = AUTO_CRLF_FALSE;
return 0;
}
diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh
index 234a94f..52c2b71 100755
--- a/t/t0020-crlf.sh
+++ b/t/t0020-crlf.sh
@@ -135,9 +135,35 @@ test_expect_success 'update with autocrlf=true' '
'
+test_expect_success 'checkout with eolconv=crlf' '
+
+ rm -f tmp one dir/two three &&
+ git config --unset-all core.autocrlf &&
+ git config core.eolconv crlf &&
+ git read-tree --reset -u HEAD &&
+
+ for f in one dir/two
+ do
+ remove_cr <"$f" >tmp && mv -f tmp $f &&
+ git update-index -- $f || {
+ echo "Eh? $f"
+ false
+ break
+ }
+ done &&
+ test "$one" = `git hash-object --stdin <one` &&
+ test "$two" = `git hash-object --stdin <dir/two` &&
+ differs=`git diff-index --cached HEAD` &&
+ test -z "$differs" || {
+ echo Oops "$differs"
+ false
+ }
+'
+
test_expect_success 'checkout with autocrlf=true' '
rm -f tmp one dir/two three &&
+ git config --unset-all core.eolconv &&
git config core.autocrlf true &&
git read-tree --reset -u HEAD &&
@@ -159,9 +185,37 @@ test_expect_success 'checkout with autocrlf=true' '
}
'
+test_expect_success 'checkout with eolconv=lf' '
+
+ rm -f tmp one dir/two three &&
+ git config --unset-all core.autocrlf &&
+ git config core.eolconv lf &&
+ git read-tree --reset -u HEAD &&
+
+ for f in one dir/two
+ do
+ if has_cr "$f"
+ then
+ echo "Eh? $f"
+ false
+ break
+ else
+ git update-index -- $f
+ fi
+ done &&
+ test "$one" = `git hash-object --stdin <one` &&
+ test "$two" = `git hash-object --stdin <dir/two` &&
+ differs=`git diff-index --cached HEAD` &&
+ test -z "$differs" || {
+ echo Oops "$differs"
+ false
+ }
+'
+
test_expect_success 'checkout with autocrlf=input' '
rm -f tmp one dir/two three &&
+ git config --unset-all core.eolconv &&
git config core.autocrlf input &&
git read-tree --reset -u HEAD &&
--
1.7.1.3.g448cb.dirty
prev parent reply other threads:[~2010-05-12 23:01 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-12 23:00 [PATCH v3 0/5] End-of-line normalization, redesigned Eyvind Bernhardsen
2010-05-12 23:00 ` [PATCH v3 1/5] autocrlf: Make it work also for un-normalized repositories Eyvind Bernhardsen
2010-05-12 23:00 ` [PATCH v3 2/5] Add tests for per-repository eol normalization Eyvind Bernhardsen
2010-05-12 23:00 ` [PATCH v3 3/5] Add " Eyvind Bernhardsen
2010-05-12 23:00 ` [RFC/PATCH v3 4/5] Rename "crlf" attribute as "eolconv" Eyvind Bernhardsen
2010-05-13 1:38 ` Linus Torvalds
2010-05-13 9:39 ` Robert Buck
2010-05-13 9:58 ` Robert Buck
2010-05-13 11:47 ` Eyvind Bernhardsen
2010-05-13 13:19 ` Robert Buck
2010-05-14 10:16 ` utf8 BOM Dmitry Potapov
2010-05-15 20:23 ` Eyvind Bernhardsen
2010-05-16 5:19 ` Dmitry Potapov
2010-05-16 10:37 ` Eyvind Bernhardsen
2010-05-16 11:26 ` Tait
2010-05-16 13:32 ` Dmitry Potapov
2010-05-13 10:59 ` [RFC/PATCH v3 4/5] Rename "crlf" attribute as "eolconv" Eyvind Bernhardsen
2010-05-13 21:45 ` Linus Torvalds
2010-05-14 2:34 ` Robert Buck
2010-05-14 4:56 ` Jonathan Nieder
2010-05-14 21:21 ` Eyvind Bernhardsen
2010-05-14 21:32 ` Eyvind Bernhardsen
2010-05-14 21:16 ` Eyvind Bernhardsen
2010-05-14 21:27 ` Linus Torvalds
2010-05-15 20:47 ` [PATCH] Add "core.eol" variable to control end-of-line conversion Eyvind Bernhardsen
2010-05-16 10:39 ` Robert Buck
2010-05-12 23:00 ` Eyvind Bernhardsen [this message]
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=d739aefee3d015b739b41e1db549c19472c3dd5a.1273700831.git.eyvind.bernhardsen@gmail.com \
--to=eyvind.bernhardsen@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=jaysoffian@gmail.com \
--cc=msysgit@googlegroups.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).