convert.c: use text_eol_is_crlf()

Add a helper function to find out, which line endings text files should get at checkout, depending on core.autocrlf and core.eol configuration variables. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Torsten Bögershausen committed Feb 5, 2016 at 17:13 UTC 4b4024f5ddca2ac14c2b15158d7cca888a8ae25e
1 file changed +14 -6
convert.c
+14 -6
@@ -149,6 +149,19 @@ const char *get_wt_convert_stats_ascii(const char *path)
149 return ret;
150 }
151
152 +static int text_eol_is_crlf(void)
153 +{
154 + if (auto_crlf == AUTO_CRLF_TRUE)
155 + return 1;
156 + else if (auto_crlf == AUTO_CRLF_INPUT)
157 + return 0;
158 + if (core_eol == EOL_CRLF)
159 + return 1;
160 + if (core_eol == EOL_UNSET && EOL_NATIVE == EOL_CRLF)
161 + return 1;
162 + return 0;
163 +}
164 +
165 static enum eol output_eol(enum crlf_action crlf_action)
166 {
167 switch (crlf_action) {
@@ -164,12 +177,7 @@ static enum eol output_eol(enum crlf_action crlf_action)
177 /* fall through */
178 case CRLF_TEXT:
179 case CRLF_AUTO:
167 - if (auto_crlf == AUTO_CRLF_TRUE)
168 - return EOL_CRLF;
169 - else if (auto_crlf == AUTO_CRLF_INPUT)
170 - return EOL_LF;
171 - else if (core_eol == EOL_UNSET)
172 - return EOL_NATIVE;
180 + return text_eol_is_crlf() ? EOL_CRLF : EOL_LF;
181 }
182 return core_eol;
183 }