Skip to content

Commit caa47ad

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

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

convert.c

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,27 +1380,22 @@ static struct stream_filter *ident_filter(const unsigned char *sha1)
13801380
struct stream_filter *get_stream_filter(const char *path, const unsigned char *sha1)
13811381
{
13821382
struct conv_attrs ca;
1383-
enum crlf_action crlf_action;
13841383
struct stream_filter *filter = NULL;
13851384

13861385
convert_attrs(&ca, path);
1387-
13881386
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;
13901391

13911392
if (ca.ident)
13921393
filter = ident_filter(sha1);
13931394

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)
14031396
filter = cascade_filter(filter, lf_to_crlf_filter());
1397+
else
1398+
filter = cascade_filter(filter, &null_filter_singleton);
14041399

14051400
return filter;
14061401
}

t/t0027-auto-crlf.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ fi
493493
export CRLF_MIX_LF_CR MIX NL
494494

495495
# Same handling with and without ident
496-
for id in ""
496+
for id in "" ident
497497
do
498498
for ceol in lf crlf native
499499
do

0 commit comments

Comments
 (0)