Make AutoCRLF ternary variable.
authorLinus Torvalds <torvalds@linux-foundation.org>
Wed, 14 Feb 2007 02:16:12 +0000 (18:16 -0800)
committerJunio C Hamano <junkio@cox.net>
Wed, 14 Feb 2007 19:19:28 +0000 (11:19 -0800)
This allows you to do:

[core]
AutoCRLF = input

and it should do only the CRLF->LF translation (ie it simplifies CRLF only
when reading working tree files, but when checking out files, it leaves
the LF alone, and doesn't turn it into a CRLF).

Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
config.c
convert.c
environment.c

index ffe02129a5a11248cf3a3970c2147c8bdf3e3ea6..e8ae919b5217816b9f3c9a201a16dc26753f7503 100644 (file)
--- a/config.c
+++ b/config.c
@@ -325,6 +325,10 @@ int git_default_config(const char *var, const char *value)
        }
 
        if (!strcmp(var, "core.autocrlf")) {
+               if (value && !strcasecmp(value, "input")) {
+                       auto_crlf = -1;
+                       return 0;
+               }
                auto_crlf = git_config_bool(var, value);
                return 0;
        }
index 13beb70582761f467ea570445afbdabfea7859eb..898bfe3eb219618e746afbe02eb4a8756eccc6aa 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -140,7 +140,7 @@ int convert_to_working_tree(const char *path, char **bufp, unsigned long *sizep)
         * based on filename patterns. Right now we just do the
         * stupid auto-CRLF one.
         */
-       if (!auto_crlf)
+       if (auto_crlf <= 0)
                return 0;
 
        size = *sizep;
index 2fa0960412755fe6d4ca93348165e6591d1fbf0d..570e32ac3cae2c1502a49a6ca1aacebb52f42ce0 100644 (file)
@@ -28,7 +28,7 @@ size_t packed_git_window_size = DEFAULT_PACKED_GIT_WINDOW_SIZE;
 size_t packed_git_limit = DEFAULT_PACKED_GIT_LIMIT;
 int pager_in_use;
 int pager_use_color = 1;
-int auto_crlf = 0;
+int auto_crlf = 0;     /* 1: both ways, -1: only when adding git objects */
 
 static const char *git_dir;
 static char *git_object_dir, *git_index_file, *git_refs_dir, *git_graft_file;