@@ -193,30 +193,30 @@ static enum eol output_eol(enum crlf_action crlf_action)
193193 return core_eol ;
194194}
195195
196- static void check_safe_crlf (const char * path , enum crlf_action crlf_action ,
196+ static void check_global_conv_flags_eol (const char * path , enum crlf_action crlf_action ,
197197 struct text_stat * old_stats , struct text_stat * new_stats ,
198- enum safe_crlf checksafe )
198+ int conv_flags )
199199{
200200 if (old_stats -> crlf && !new_stats -> crlf ) {
201201 /*
202202 * CRLFs would not be restored by checkout
203203 */
204- if (checksafe == SAFE_CRLF_WARN )
204+ if (conv_flags & CONV_EOL_RNDTRP_DIE )
205+ die (_ ("CRLF would be replaced by LF in %s." ), path );
206+ else if (conv_flags & CONV_EOL_RNDTRP_WARN )
205207 warning (_ ("CRLF will be replaced by LF in %s.\n"
206208 "The file will have its original line"
207209 " endings in your working directory." ), path );
208- else /* i.e. SAFE_CRLF_FAIL */
209- die (_ ("CRLF would be replaced by LF in %s." ), path );
210210 } else if (old_stats -> lonelf && !new_stats -> lonelf ) {
211211 /*
212212 * CRLFs would be added by checkout
213213 */
214- if (checksafe == SAFE_CRLF_WARN )
214+ if (conv_flags & CONV_EOL_RNDTRP_DIE )
215+ die (_ ("LF would be replaced by CRLF in %s" ), path );
216+ else if (conv_flags & CONV_EOL_RNDTRP_WARN )
215217 warning (_ ("LF will be replaced by CRLF in %s.\n"
216218 "The file will have its original line"
217219 " endings in your working directory." ), path );
218- else /* i.e. SAFE_CRLF_FAIL */
219- die (_ ("LF would be replaced by CRLF in %s" ), path );
220220 }
221221}
222222
@@ -268,7 +268,7 @@ static int will_convert_lf_to_crlf(size_t len, struct text_stat *stats,
268268static int crlf_to_git (const struct index_state * istate ,
269269 const char * path , const char * src , size_t len ,
270270 struct strbuf * buf ,
271- enum crlf_action crlf_action , enum safe_crlf checksafe )
271+ enum crlf_action crlf_action , int conv_flags )
272272{
273273 struct text_stat stats ;
274274 char * dst ;
@@ -298,12 +298,12 @@ static int crlf_to_git(const struct index_state *istate,
298298 * unless we want to renormalize in a merge or
299299 * cherry-pick.
300300 */
301- if ((checksafe != SAFE_CRLF_RENORMALIZE ) &&
301+ if ((!( conv_flags & CONV_EOL_RENORMALIZE ) ) &&
302302 has_crlf_in_index (istate , path ))
303303 convert_crlf_into_lf = 0 ;
304304 }
305- if ((checksafe == SAFE_CRLF_WARN ||
306- ( checksafe == SAFE_CRLF_FAIL )) && len ) {
305+ if ((( conv_flags & CONV_EOL_RNDTRP_WARN ) ||
306+ (( conv_flags & CONV_EOL_RNDTRP_DIE ) && len )) ) {
307307 struct text_stat new_stats ;
308308 memcpy (& new_stats , & stats , sizeof (new_stats ));
309309 /* simulate "git add" */
@@ -316,7 +316,7 @@ static int crlf_to_git(const struct index_state *istate,
316316 new_stats .crlf += new_stats .lonelf ;
317317 new_stats .lonelf = 0 ;
318318 }
319- check_safe_crlf (path , crlf_action , & stats , & new_stats , checksafe );
319+ check_global_conv_flags_eol (path , crlf_action , & stats , & new_stats , conv_flags );
320320 }
321321 if (!convert_crlf_into_lf )
322322 return 0 ;
@@ -1129,7 +1129,7 @@ const char *get_convert_attr_ascii(const char *path)
11291129
11301130int convert_to_git (const struct index_state * istate ,
11311131 const char * path , const char * src , size_t len ,
1132- struct strbuf * dst , enum safe_crlf checksafe )
1132+ struct strbuf * dst , int conv_flags )
11331133{
11341134 int ret = 0 ;
11351135 struct conv_attrs ca ;
@@ -1144,8 +1144,8 @@ int convert_to_git(const struct index_state *istate,
11441144 src = dst -> buf ;
11451145 len = dst -> len ;
11461146 }
1147- if (checksafe != SAFE_CRLF_KEEP_CRLF ) {
1148- ret |= crlf_to_git (istate , path , src , len , dst , ca .crlf_action , checksafe );
1147+ if (!( conv_flags & CONV_EOL_KEEP_CRLF ) ) {
1148+ ret |= crlf_to_git (istate , path , src , len , dst , ca .crlf_action , conv_flags );
11491149 if (ret && dst ) {
11501150 src = dst -> buf ;
11511151 len = dst -> len ;
@@ -1156,7 +1156,7 @@ int convert_to_git(const struct index_state *istate,
11561156
11571157void convert_to_git_filter_fd (const struct index_state * istate ,
11581158 const char * path , int fd , struct strbuf * dst ,
1159- enum safe_crlf checksafe )
1159+ int conv_flags )
11601160{
11611161 struct conv_attrs ca ;
11621162 convert_attrs (& ca , path );
@@ -1167,7 +1167,7 @@ void convert_to_git_filter_fd(const struct index_state *istate,
11671167 if (!apply_filter (path , NULL , 0 , fd , dst , ca .drv , CAP_CLEAN , NULL ))
11681168 die ("%s: clean filter '%s' failed" , path , ca .drv -> name );
11691169
1170- crlf_to_git (istate , path , dst -> buf , dst -> len , dst , ca .crlf_action , checksafe );
1170+ crlf_to_git (istate , path , dst -> buf , dst -> len , dst , ca .crlf_action , conv_flags );
11711171 ident_to_git (path , dst -> buf , dst -> len , dst , ca .ident );
11721172}
11731173
@@ -1226,7 +1226,7 @@ int renormalize_buffer(const struct index_state *istate, const char *path,
12261226 src = dst -> buf ;
12271227 len = dst -> len ;
12281228 }
1229- return ret | convert_to_git (istate , path , src , len , dst , SAFE_CRLF_RENORMALIZE );
1229+ return ret | convert_to_git (istate , path , src , len , dst , CONV_EOL_RENORMALIZE );
12301230}
12311231
12321232/*****************************************************************
0 commit comments