Skip to content

Commit a511584

Browse files
committed
crlf: update checkout logic to reflect Git 2.9+ behaviour
Signed-off-by: Sven Strickroth <email@cs-ware.de>
1 parent ad5a696 commit a511584

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ v0.27 + 1
33

44
### Changes or improvements
55

6+
* Update CrLf checkout code to vanilla Git >= 2.9 logic
7+
68
### API additions
79

810
### API removals

src/crlf.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ static int crlf_input_action(struct crlf_attrs *ca)
7171
if (ca->eol == GIT_EOL_LF)
7272
return GIT_CRLF_INPUT;
7373

74+
if (ca->crlf_action == GIT_CRLF_AUTO)
75+
return GIT_CRLF_AUTO;
76+
7477
if (ca->eol == GIT_EOL_CRLF)
7578
return GIT_CRLF_CRLF;
7679

@@ -200,6 +203,8 @@ static const char *line_ending(struct crlf_attrs *ca)
200203
break;
201204

202205
case GIT_CRLF_AUTO:
206+
if (ca->eol == GIT_EOL_CRLF)
207+
return "\r\n";
203208
case GIT_CRLF_TEXT:
204209
break;
205210

@@ -253,8 +258,7 @@ static int crlf_apply_to_workdir(
253258
ca->crlf_action == GIT_CRLF_GUESS) {
254259

255260
/* If we have any existing CR or CRLF line endings, do nothing */
256-
if (ca->crlf_action == GIT_CRLF_GUESS &&
257-
stats.cr > 0 && stats.crlf > 0)
261+
if (stats.cr > 0 && stats.crlf > 0)
258262
return GIT_PASSTHROUGH;
259263

260264
/* If we have bare CR characters, do nothing */
@@ -314,7 +318,7 @@ static int crlf_check(
314318
ca.auto_crlf == GIT_AUTO_CRLF_FALSE)
315319
return GIT_PASSTHROUGH;
316320

317-
if (ca.auto_crlf == GIT_AUTO_CRLF_INPUT &&
321+
if (ca.auto_crlf == GIT_AUTO_CRLF_INPUT && ca.eol != GIT_EOL_CRLF &&
318322
git_filter_source_mode(src) == GIT_FILTER_SMUDGE)
319323
return GIT_PASSTHROUGH;
320324
}

0 commit comments

Comments
 (0)