From: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
To: git@vger.kernel.org
Cc: hasan.aljudy@gmail.com, kusmabite@googlemail.com,
torvalds@linux-foundation.org, prohaska@zib.de,
gitster@pobox.com
Subject: [PATCH/RFC 1/3] Add "auto-eol" attribute and "core.eolStyle" config variable
Date: Fri, 7 May 2010 00:27:33 +0200 [thread overview]
Message-ID: <a8bc571bb092967a1e481f74f3e97ced5135ff34.1273183206.git.eyvind.bernhardsen@gmail.com> (raw)
In-Reply-To: <cover.1273183206.git.eyvind.bernhardsen@gmail.com>
Introduce a new attribute called "auto-eol" and a config variable,
"core.eolStyle", which will enable line ending normalisation using the
autocrlf mechanism.
The intent is to enable autocrlf in an alternative way, splitting the
existing "core.autocrlf" config variable into two:
- a per-repository "line endings should be normalised in this
repository" setting, activated by setting the auto-eol attribute
(usually on all files in the repository)
- a config variable, "core.eolStyle" which lets the user decide which
line endings are preferred in the working directory
Possible values for "core.eolStyle" are:
- "lf", meaning that LF line endings are preferred
- "crlf", meaning that CRLF line endings are preferred
- "native" (the default), crlf or lf according to platform
- "false", which disables end-of-line conversion even when auto-eol is
set
"core.autocrlf" will override auto-eol when set to anything but "false".
Signed-off-by: Eyvind Bernhardsen <eyvind.bernhardsen@gmail.com>
---
Makefile | 3 +++
cache.h | 19 +++++++++++++++++++
config.c | 16 +++++++++++++++-
environment.c | 1 +
4 files changed, 38 insertions(+), 1 deletions(-)
diff --git a/Makefile b/Makefile
index 910f471..419532e 100644
--- a/Makefile
+++ b/Makefile
@@ -224,6 +224,8 @@ all::
#
# Define CHECK_HEADER_DEPENDENCIES to check for problems in the hard-coded
# dependency rules.
+#
+# Define NATIVE_CRLF if your platform uses CRLF for line endings.
GIT-VERSION-FILE: FORCE
@$(SHELL_PATH) ./GIT-VERSION-GEN
@@ -989,6 +991,7 @@ ifeq ($(uname_S),Windows)
NO_CURL = YesPlease
NO_PYTHON = YesPlease
BLK_SHA1 = YesPlease
+ NATIVE_CRLF = YesPlease
CC = compat/vcbuild/scripts/clink.pl
AR = compat/vcbuild/scripts/lib.pl
diff --git a/cache.h b/cache.h
index 5eb0573..690511e 100644
--- a/cache.h
+++ b/cache.h
@@ -561,6 +561,25 @@ enum safe_crlf {
extern enum safe_crlf safe_crlf;
+enum auto_crlf {
+ AUTO_CRLF_FALSE = 0,
+ AUTO_CRLF_TRUE = 1,
+ AUTO_CRLF_INPUT = -1,
+};
+
+enum eol_style {
+ EOL_STYLE_FALSE = AUTO_CRLF_FALSE,
+ EOL_STYLE_CRLF = AUTO_CRLF_TRUE,
+ EOL_STYLE_LF = AUTO_CRLF_INPUT,
+#ifdef NATIVE_CRLF
+ EOL_STYLE_NATIVE = EOL_STYLE_CRLF,
+#else
+ EOL_STYLE_NATIVE = EOL_STYLE_LF,
+#endif
+};
+
+extern enum eol_style eol_style;
+
enum branch_track {
BRANCH_TRACK_UNSPECIFIED = -1,
BRANCH_TRACK_NEVER = 0,
diff --git a/config.c b/config.c
index 6963fbe..8a11052 100644
--- a/config.c
+++ b/config.c
@@ -461,7 +461,7 @@ static int git_default_core_config(const char *var, const char *value)
if (!strcmp(var, "core.autocrlf")) {
if (value && !strcasecmp(value, "input")) {
- auto_crlf = -1;
+ auto_crlf = AUTO_CRLF_INPUT;
return 0;
}
auto_crlf = git_config_bool(var, value);
@@ -477,6 +477,20 @@ static int git_default_core_config(const char *var, const char *value)
return 0;
}
+ if (!strcmp(var, "core.eolstyle")) {
+ if (value && !strcasecmp(value, "lf"))
+ eol_style = EOL_STYLE_LF;
+ else if (value && !strcasecmp(value, "crlf"))
+ eol_style = EOL_STYLE_CRLF;
+ else if (value && !strcasecmp(value, "native"))
+ eol_style = EOL_STYLE_NATIVE;
+ else if (! git_config_bool(var, value))
+ eol_style = EOL_STYLE_FALSE;
+ else
+ return error("Malformed value for %s", var);
+ return 0;
+ }
+
if (!strcmp(var, "core.notesref")) {
notes_ref_name = xstrdup(value);
return 0;
diff --git a/environment.c b/environment.c
index 876c5e5..05cd1d5 100644
--- a/environment.c
+++ b/environment.c
@@ -40,6 +40,7 @@ const char *editor_program;
const char *excludes_file;
int auto_crlf = 0; /* 1: both ways, -1: only when adding git objects */
int read_replace_refs = 1;
+enum eol_style eol_style = EOL_STYLE_NATIVE;
enum safe_crlf safe_crlf = SAFE_CRLF_WARN;
unsigned whitespace_rule_cfg = WS_DEFAULT_RULE;
enum branch_track git_branch_track = BRANCH_TRACK_REMOTE;
--
1.7.1.3.gb95c9
next prev parent reply other threads:[~2010-05-06 22:27 UTC|newest]
Thread overview: 82+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-05 10:01 What should be the CRLF policy when win + Linux? mat
2010-05-05 13:27 ` Ramkumar Ramachandra
2010-05-06 9:27 ` mat
2010-05-06 10:03 ` Erik Faye-Lund
2010-05-06 2:35 ` hasen j
2010-05-06 7:29 ` Wilbert van Dolleweerd
2010-05-06 15:34 ` hasen j
2010-05-06 17:15 ` Linus Torvalds
2010-05-06 17:26 ` Erik Faye-Lund
2010-05-06 20:00 ` hasen j
2010-05-06 20:23 ` Linus Torvalds
2010-05-06 20:40 ` Erik Faye-Lund
2010-05-06 22:14 ` hasen j
2010-05-06 23:25 ` Erik Faye-Lund
2010-05-18 15:13 ` Anthony W. Youngman
2010-05-06 22:27 ` [PATCH/RFC 0/3] Per-repository end-of-line normalization Eyvind Bernhardsen
2010-05-06 22:27 ` Eyvind Bernhardsen [this message]
2010-05-06 22:27 ` [PATCH/RFC 2/3] Add tests for per-repository eol normalization Eyvind Bernhardsen
2010-05-06 22:27 ` [PATCH/RFC 3/3] Add " Eyvind Bernhardsen
2010-05-06 23:38 ` [PATCH/RFC 0/3] Per-repository end-of-line normalization Avery Pennarun
2010-05-06 23:54 ` Avery Pennarun
2010-05-07 8:45 ` Erik Faye-Lund
2010-05-07 16:33 ` Junio C Hamano
2010-05-07 16:57 ` Avery Pennarun
2010-05-07 17:10 ` Linus Torvalds
2010-05-07 19:02 ` Linus Torvalds
2010-05-07 19:11 ` Avery Pennarun
2010-05-07 19:16 ` Linus Torvalds
2010-05-07 19:35 ` Avery Pennarun
2010-05-07 19:45 ` Linus Torvalds
2010-05-07 19:58 ` Avery Pennarun
2010-05-07 20:06 ` Linus Torvalds
2010-05-07 20:17 ` Linus Torvalds
2010-05-07 20:42 ` Eyvind Bernhardsen
2010-05-07 20:57 ` Linus Torvalds
2010-05-07 21:17 ` Eyvind Bernhardsen
2010-05-07 21:23 ` Linus Torvalds
2010-05-07 21:30 ` Avery Pennarun
2010-05-07 21:37 ` Eyvind Bernhardsen
2010-05-07 21:58 ` Linus Torvalds
2010-05-07 21:54 ` Linus Torvalds
2010-05-07 22:14 ` Linus Torvalds
2010-05-07 22:34 ` Avery Pennarun
2010-05-07 22:54 ` hasen j
2010-05-07 23:18 ` Linus Torvalds
2010-05-07 23:47 ` hasen j
2010-05-07 23:50 ` Linus Torvalds
2010-05-08 0:19 ` hasen j
2010-05-08 0:33 ` Linus Torvalds
2010-05-08 1:39 ` hasen j
2010-05-08 1:49 ` Linus Torvalds
2010-05-08 2:49 ` hasen j
2010-05-08 3:31 ` Robert Buck
2010-05-08 3:45 ` Avery Pennarun
2010-05-08 10:36 ` hasen j
2010-05-08 11:36 ` Robert Buck
2010-05-08 3:34 ` Avery Pennarun
2010-05-08 0:31 ` Avery Pennarun
2010-05-07 22:19 ` Avery Pennarun
2010-05-08 20:49 ` Dmitry Potapov
2010-05-08 21:54 ` Linus Torvalds
2010-05-08 23:42 ` Dmitry Potapov
2010-05-09 7:49 ` Eyvind Bernhardsen
2010-05-09 10:35 ` Robert Buck
2010-05-07 20:58 ` Avery Pennarun
2010-05-07 19:23 ` Eyvind Bernhardsen
2010-05-07 19:31 ` Nicolas Pitre
2010-05-07 19:36 ` Avery Pennarun
2010-05-07 20:29 ` Nicolas Pitre
2010-05-07 21:00 ` Avery Pennarun
2010-05-07 21:12 ` Nicolas Pitre
2010-05-07 21:26 ` Avery Pennarun
2010-05-07 22:09 ` A Large Angry SCM
2010-05-07 22:10 ` Avery Pennarun
2010-05-07 19:40 ` Linus Torvalds
2010-05-07 20:32 ` Nicolas Pitre
2010-05-07 19:06 ` Junio C Hamano
2010-05-07 19:25 ` Eyvind Bernhardsen
2010-05-07 19:41 ` Finn Arne Gangstad
2010-05-07 20:06 ` Avery Pennarun
2010-05-07 20:11 ` Eyvind Bernhardsen
2010-05-07 7:15 ` What should be the CRLF policy when win + Linux? Gelonida
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=a8bc571bb092967a1e481f74f3e97ced5135ff34.1273183206.git.eyvind.bernhardsen@gmail.com \
--to=eyvind.bernhardsen@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hasan.aljudy@gmail.com \
--cc=kusmabite@googlemail.com \
--cc=prohaska@zib.de \
--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).