convert.c: ident + core.autocrlf didn't work

When the ident attributes is set, get_stream_filter() did not obey core.autocrlf=true, and the file was checked out with LF. Change the rule when a streaming filter can be used: - if an external filter is specified, don't use a stream filter. - if the worktree eol is CRLF and "auto" is active, don't use a stream filter. - Otherwise the stream filter can be used. Add test cases in t0027. Signed-off-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Torsten Bögershausen committed Apr 25, 2016 at 18:56 UTC caa47adc5a68045bfb9e88fcfee0e50589d129df
2 files changed +8 -13
convert.c
+7 -12
@@ -1380,27 +1380,22 @@ static struct stream_filter *ident_filter(const unsigned char *sha1)
1380 struct stream_filter *get_stream_filter(const char *path, const unsigned char *sha1)
1381 {
1382 struct conv_attrs ca;
1383 - enum crlf_action crlf_action;
1383 struct stream_filter *filter = NULL;
1384
1385 convert_attrs(&ca, path);
1387 -
1386 if (ca.drv && (ca.drv->smudge || ca.drv->clean))
1389 - return filter;
1387 + return NULL;
1388 +
1389 + if (ca.crlf_action == CRLF_AUTO || ca.crlf_action == CRLF_AUTO_CRLF)
1390 + return NULL;
1391
1392 if (ca.ident)
1393 filter = ident_filter(sha1);
1394
1394 - crlf_action = ca.crlf_action;
1395 -
1396 - if ((crlf_action == CRLF_BINARY) ||
1397 - crlf_action == CRLF_AUTO_INPUT ||
1398 - (crlf_action == CRLF_TEXT_INPUT))
1399 - filter = cascade_filter(filter, &null_filter_singleton);
1400 -
1401 - else if (output_eol(crlf_action) == EOL_CRLF &&
1402 - !(crlf_action == CRLF_AUTO || crlf_action == CRLF_AUTO_CRLF))
1395 + if (output_eol(ca.crlf_action) == EOL_CRLF)
1396 filter = cascade_filter(filter, lf_to_crlf_filter());
1397 + else
1398 + filter = cascade_filter(filter, &null_filter_singleton);
1399
1400 return filter;
1401 }
t/t0027-auto-crlf.sh
+1 -1
@@ -493,7 +493,7 @@ fi
493 export CRLF_MIX_LF_CR MIX NL
494
495 # Same handling with and without ident
496 -for id in ""
496 +for id in "" ident
497 do
498 for ceol in lf crlf native
499 do