crlf: give Unix the glory of autocrlf=true Perform LF->CRLF for core.autocrlf=true on non-Win32 because core git does.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
diff --git a/src/crlf.c b/src/crlf.c
index 2fe8a5f..f391137 100644
--- a/src/crlf.c
+++ b/src/crlf.c
@@ -193,28 +193,29 @@ static const char *line_ending(struct crlf_attrs *ca)
case GIT_CRLF_CRLF:
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_TEXT:
- case GIT_CRLF_GUESS:
break;
default:
goto line_ending_error;
}
- switch (ca->eol) {
- case GIT_EOL_UNSET:
- return GIT_EOL_NATIVE == GIT_EOL_CRLF ? "\r\n" : "\n";
-
- case GIT_EOL_CRLF:
+ if (ca->auto_crlf == GIT_AUTO_CRLF_TRUE)
return "\r\n";
-
- case GIT_EOL_LF:
+ else if (ca->auto_crlf == GIT_AUTO_CRLF_INPUT)
return "\n";
-
- default:
- goto line_ending_error;
- }
+ else if (ca->eol == GIT_EOL_UNSET)
+ return GIT_EOL_NATIVE == GIT_EOL_CRLF ? "\r\n" : "\n";
+ else if (ca->eol == GIT_EOL_LF)
+ return "\n";
+ else if (ca->eol == GIT_EOL_CRLF)
+ return "\r\n";
line_ending_error:
giterr_set(GITERR_INVALID, "Invalid input to line ending filter");
@@ -299,7 +300,7 @@ static int crlf_check(
return GIT_PASSTHROUGH;
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)) {
error = git_repository__cvar(