Skip to content

Commit 4b4024f

Browse files
tboegigitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent bb211b4 commit 4b4024f

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

convert.c

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,19 @@ const char *get_wt_convert_stats_ascii(const char *path)
149149
return ret;
150150
}
151151

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+
152165
static enum eol output_eol(enum crlf_action crlf_action)
153166
{
154167
switch (crlf_action) {
@@ -164,12 +177,7 @@ static enum eol output_eol(enum crlf_action crlf_action)
164177
/* fall through */
165178
case CRLF_TEXT:
166179
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;
173181
}
174182
return core_eol;
175183
}

0 commit comments

Comments
 (0)