]> granicus.if.org Git - git/commitdiff
convert: add SAFE_CRLF_KEEP_CRLF
authorTorsten Bögershausen <tboegi@web.de>
Sun, 13 Aug 2017 08:51:04 +0000 (10:51 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Aug 2017 17:21:17 +0000 (10:21 -0700)
When convert_to_git() is called, the caller may want to keep CRLF to
be kept as CRLF (and not converted into LF).

This will be used in the next commit, when apply works with files
that have CRLF and patches are applied onto these files.

Add the new value "SAFE_CRLF_KEEP_CRLF" to safe_crlf.

Prepare convert_to_git() to be able to run the clean filter, skip
the CRLF conversion and run the ident filter.

Signed-off-by: Torsten Bögershausen <tboegi@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
convert.c
convert.h

index deaf0ba7b30ffa4e0003649985ef1594ee2ac049..040123b4fe6d208670adfaa86266c88d02feca5d 100644 (file)
--- a/convert.c
+++ b/convert.c
@@ -1104,10 +1104,12 @@ int convert_to_git(const struct index_state *istate,
                src = dst->buf;
                len = dst->len;
        }
-       ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, checksafe);
-       if (ret && dst) {
-               src = dst->buf;
-               len = dst->len;
+       if (checksafe != SAFE_CRLF_KEEP_CRLF) {
+               ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, checksafe);
+               if (ret && dst) {
+                       src = dst->buf;
+                       len = dst->len;
+               }
        }
        return ret | ident_to_git(path, src, len, dst, ca.ident);
 }
index cecf59d1aa15f234473dc16520c0a6647e255280..cabd5ed6dd965806551436829c72a89d4e63a7a4 100644 (file)
--- a/convert.h
+++ b/convert.h
@@ -10,7 +10,8 @@ enum safe_crlf {
        SAFE_CRLF_FALSE = 0,
        SAFE_CRLF_FAIL = 1,
        SAFE_CRLF_WARN = 2,
-       SAFE_CRLF_RENORMALIZE = 3
+       SAFE_CRLF_RENORMALIZE = 3,
+       SAFE_CRLF_KEEP_CRLF = 4
 };
 
 extern enum safe_crlf safe_crlf;