Skip to content

Commit 2fea9de

Browse files
tboegigitster
authored andcommitted
convert: add SAFE_CRLF_KEEP_CRLF
When convert_to_git() is called, the caller may want to keep CRLF to be kept as CRLF (and not converted into LF). This will be used in the next commit, when apply works with files that have CRLF and patches are applied onto these files. Add the new value "SAFE_CRLF_KEEP_CRLF" to safe_crlf. Prepare convert_to_git() to be able to run the clean filter, skip the CRLF conversion and run the ident filter. Signed-off-by: Torsten Bögershausen <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d7268b commit 2fea9de

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

convert.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,10 +1104,12 @@ int convert_to_git(const struct index_state *istate,
11041104
src = dst->buf;
11051105
len = dst->len;
11061106
}
1107-
ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, checksafe);
1108-
if (ret && dst) {
1109-
src = dst->buf;
1110-
len = dst->len;
1107+
if (checksafe != SAFE_CRLF_KEEP_CRLF) {
1108+
ret |= crlf_to_git(istate, path, src, len, dst, ca.crlf_action, checksafe);
1109+
if (ret && dst) {
1110+
src = dst->buf;
1111+
len = dst->len;
1112+
}
11111113
}
11121114
return ret | ident_to_git(path, src, len, dst, ca.ident);
11131115
}

convert.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ enum safe_crlf {
1010
SAFE_CRLF_FALSE = 0,
1111
SAFE_CRLF_FAIL = 1,
1212
SAFE_CRLF_WARN = 2,
13-
SAFE_CRLF_RENORMALIZE = 3
13+
SAFE_CRLF_RENORMALIZE = 3,
14+
SAFE_CRLF_KEEP_CRLF = 4
1415
};
1516

1617
extern enum safe_crlf safe_crlf;

0 commit comments

Comments
 (0)