Commit 146d0d08 by Edward Thomson Committed by Edward Thomson

crlf: give Unix the glory of autocrlf=true

Perform LF->CRLF for core.autocrlf=true on non-Win32 because core
git does.
parent 1e46d545
...@@ -193,28 +193,29 @@ static const char *line_ending(struct crlf_attrs *ca) ...@@ -193,28 +193,29 @@ static const char *line_ending(struct crlf_attrs *ca)
case GIT_CRLF_CRLF: case GIT_CRLF_CRLF:
return "\r\n"; return "\r\n";
case GIT_CRLF_GUESS:
if (ca->auto_crlf == GIT_AUTO_CRLF_FALSE)
return "\n";
break;
case GIT_CRLF_AUTO: case GIT_CRLF_AUTO:
case GIT_CRLF_TEXT: case GIT_CRLF_TEXT:
case GIT_CRLF_GUESS:
break; break;
default: default:
goto line_ending_error; goto line_ending_error;
} }
switch (ca->eol) { if (ca->auto_crlf == GIT_AUTO_CRLF_TRUE)
case GIT_EOL_UNSET:
return GIT_EOL_NATIVE == GIT_EOL_CRLF ? "\r\n" : "\n";
case GIT_EOL_CRLF:
return "\r\n"; return "\r\n";
else if (ca->auto_crlf == GIT_AUTO_CRLF_INPUT)
case GIT_EOL_LF:
return "\n"; return "\n";
else if (ca->eol == GIT_EOL_UNSET)
default: return GIT_EOL_NATIVE == GIT_EOL_CRLF ? "\r\n" : "\n";
goto line_ending_error; else if (ca->eol == GIT_EOL_LF)
} return "\n";
else if (ca->eol == GIT_EOL_CRLF)
return "\r\n";
line_ending_error: line_ending_error:
giterr_set(GITERR_INVALID, "Invalid input to line ending filter"); giterr_set(GITERR_INVALID, "Invalid input to line ending filter");
...@@ -299,7 +300,7 @@ static int crlf_check( ...@@ -299,7 +300,7 @@ static int crlf_check(
return GIT_PASSTHROUGH; return GIT_PASSTHROUGH;
if (ca.crlf_action == GIT_CRLF_GUESS || if (ca.crlf_action == GIT_CRLF_GUESS ||
(ca.crlf_action == GIT_CRLF_AUTO && ((ca.crlf_action == GIT_CRLF_AUTO || ca.crlf_action == GIT_CRLF_TEXT) &&
git_filter_source_mode(src) == GIT_FILTER_SMUDGE)) { git_filter_source_mode(src) == GIT_FILTER_SMUDGE)) {
error = git_repository__cvar( error = git_repository__cvar(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment