1212 * translation when the "text" attribute or "auto_crlf" option is set.
1313 */
1414
15- enum action {
15+ enum crlf_action {
1616 CRLF_GUESS = -1 ,
1717 CRLF_BINARY = 0 ,
1818 CRLF_TEXT ,
@@ -94,9 +94,9 @@ static int is_binary(unsigned long size, struct text_stat *stats)
9494 return 0 ;
9595}
9696
97- static enum eol determine_output_conversion (enum action action )
97+ static enum eol output_eol (enum crlf_action crlf_action )
9898{
99- switch (action ) {
99+ switch (crlf_action ) {
100100 case CRLF_BINARY :
101101 return EOL_UNSET ;
102102 case CRLF_CRLF :
@@ -119,13 +119,13 @@ static enum eol determine_output_conversion(enum action action)
119119 return core_eol ;
120120}
121121
122- static void check_safe_crlf (const char * path , enum action action ,
122+ static void check_safe_crlf (const char * path , enum crlf_action crlf_action ,
123123 struct text_stat * stats , enum safe_crlf checksafe )
124124{
125125 if (!checksafe )
126126 return ;
127127
128- if (determine_output_conversion ( action ) == EOL_LF ) {
128+ if (output_eol ( crlf_action ) == EOL_LF ) {
129129 /*
130130 * CRLFs would not be restored by checkout:
131131 * check if we'd remove CRLFs
@@ -136,7 +136,7 @@ static void check_safe_crlf(const char *path, enum action action,
136136 else /* i.e. SAFE_CRLF_FAIL */
137137 die ("CRLF would be replaced by LF in %s." , path );
138138 }
139- } else if (determine_output_conversion ( action ) == EOL_CRLF ) {
139+ } else if (output_eol ( crlf_action ) == EOL_CRLF ) {
140140 /*
141141 * CRLFs would be added by checkout:
142142 * check if we have "naked" LFs
@@ -188,18 +188,19 @@ static int has_cr_in_index(const char *path)
188188}
189189
190190static int crlf_to_git (const char * path , const char * src , size_t len ,
191- struct strbuf * buf , enum action action , enum safe_crlf checksafe )
191+ struct strbuf * buf ,
192+ enum crlf_action crlf_action , enum safe_crlf checksafe )
192193{
193194 struct text_stat stats ;
194195 char * dst ;
195196
196- if (action == CRLF_BINARY ||
197- (action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE ) || !len )
197+ if (crlf_action == CRLF_BINARY ||
198+ (crlf_action == CRLF_GUESS && auto_crlf == AUTO_CRLF_FALSE ) || !len )
198199 return 0 ;
199200
200201 gather_stats (src , len , & stats );
201202
202- if (action == CRLF_AUTO || action == CRLF_GUESS ) {
203+ if (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS ) {
203204 /*
204205 * We're currently not going to even try to convert stuff
205206 * that has bare CR characters. Does anybody do that crazy
@@ -214,7 +215,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
214215 if (is_binary (len , & stats ))
215216 return 0 ;
216217
217- if (action == CRLF_GUESS ) {
218+ if (crlf_action == CRLF_GUESS ) {
218219 /*
219220 * If the file in the index has any CR in it, do not convert.
220221 * This is the new safer autocrlf handling.
@@ -224,7 +225,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
224225 }
225226 }
226227
227- check_safe_crlf (path , action , & stats , checksafe );
228+ check_safe_crlf (path , crlf_action , & stats , checksafe );
228229
229230 /* Optimization: No CR? Nothing to convert, regardless. */
230231 if (!stats .cr )
@@ -234,7 +235,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
234235 if (strbuf_avail (buf ) + buf -> len < len )
235236 strbuf_grow (buf , len - buf -> len );
236237 dst = buf -> buf ;
237- if (action == CRLF_AUTO || action == CRLF_GUESS ) {
238+ if (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS ) {
238239 /*
239240 * If we guessed, we already know we rejected a file with
240241 * lone CR, and we can strip a CR without looking at what
@@ -257,12 +258,12 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
257258}
258259
259260static int crlf_to_worktree (const char * path , const char * src , size_t len ,
260- struct strbuf * buf , enum action action )
261+ struct strbuf * buf , enum crlf_action crlf_action )
261262{
262263 char * to_free = NULL ;
263264 struct text_stat stats ;
264265
265- if (!len || determine_output_conversion ( action ) != EOL_CRLF )
266+ if (!len || output_eol ( crlf_action ) != EOL_CRLF )
266267 return 0 ;
267268
268269 gather_stats (src , len , & stats );
@@ -275,8 +276,8 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,
275276 if (stats .lf == stats .crlf )
276277 return 0 ;
277278
278- if (action == CRLF_AUTO || action == CRLF_GUESS ) {
279- if (action == CRLF_GUESS ) {
279+ if (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS ) {
280+ if (crlf_action == CRLF_GUESS ) {
280281 /* If we have any CR or CRLF line endings, we do not touch it */
281282 /* This is the new safer autocrlf-handling */
282283 if (stats .cr > 0 || stats .crlf > 0 )
@@ -715,7 +716,7 @@ static int git_path_check_ident(const char *path, struct git_attr_check *check)
715716 return !!ATTR_TRUE (value );
716717}
717718
718- static enum action determine_action (enum action text_attr , enum eol eol_attr )
719+ static enum crlf_action input_crlf_action (enum crlf_action text_attr , enum eol eol_attr )
719720{
720721 if (text_attr == CRLF_BINARY )
721722 return CRLF_BINARY ;
@@ -730,17 +731,17 @@ int convert_to_git(const char *path, const char *src, size_t len,
730731 struct strbuf * dst , enum safe_crlf checksafe )
731732{
732733 struct git_attr_check check [5 ];
733- enum action action = CRLF_GUESS ;
734+ enum crlf_action crlf_action = CRLF_GUESS ;
734735 enum eol eol_attr = EOL_UNSET ;
735736 int ident = 0 , ret = 0 ;
736737 const char * filter = NULL ;
737738
738739 setup_convert_check (check );
739740 if (!git_checkattr (path , ARRAY_SIZE (check ), check )) {
740741 struct convert_driver * drv ;
741- action = git_path_check_crlf (path , check + 4 );
742- if (action == CRLF_GUESS )
743- action = git_path_check_crlf (path , check + 0 );
742+ crlf_action = git_path_check_crlf (path , check + 4 );
743+ if (crlf_action == CRLF_GUESS )
744+ crlf_action = git_path_check_crlf (path , check + 0 );
744745 ident = git_path_check_ident (path , check + 1 );
745746 drv = git_path_check_convert (path , check + 2 );
746747 eol_attr = git_path_check_eol (path , check + 3 );
@@ -753,8 +754,8 @@ int convert_to_git(const char *path, const char *src, size_t len,
753754 src = dst -> buf ;
754755 len = dst -> len ;
755756 }
756- action = determine_action ( action , eol_attr );
757- ret |= crlf_to_git (path , src , len , dst , action , checksafe );
757+ crlf_action = input_crlf_action ( crlf_action , eol_attr );
758+ ret |= crlf_to_git (path , src , len , dst , crlf_action , checksafe );
758759 if (ret ) {
759760 src = dst -> buf ;
760761 len = dst -> len ;
@@ -767,17 +768,17 @@ static int convert_to_working_tree_internal(const char *path, const char *src,
767768 int normalizing )
768769{
769770 struct git_attr_check check [5 ];
770- enum action action = CRLF_GUESS ;
771+ enum crlf_action crlf_action = CRLF_GUESS ;
771772 enum eol eol_attr = EOL_UNSET ;
772773 int ident = 0 , ret = 0 ;
773774 const char * filter = NULL ;
774775
775776 setup_convert_check (check );
776777 if (!git_checkattr (path , ARRAY_SIZE (check ), check )) {
777778 struct convert_driver * drv ;
778- action = git_path_check_crlf (path , check + 4 );
779- if (action == CRLF_GUESS )
780- action = git_path_check_crlf (path , check + 0 );
779+ crlf_action = git_path_check_crlf (path , check + 4 );
780+ if (crlf_action == CRLF_GUESS )
781+ crlf_action = git_path_check_crlf (path , check + 0 );
781782 ident = git_path_check_ident (path , check + 1 );
782783 drv = git_path_check_convert (path , check + 2 );
783784 eol_attr = git_path_check_eol (path , check + 3 );
@@ -795,8 +796,8 @@ static int convert_to_working_tree_internal(const char *path, const char *src,
795796 * is a smudge filter. The filter might expect CRLFs.
796797 */
797798 if (filter || !normalizing ) {
798- action = determine_action ( action , eol_attr );
799- ret |= crlf_to_worktree (path , src , len , dst , action );
799+ crlf_action = input_crlf_action ( crlf_action , eol_attr );
800+ ret |= crlf_to_worktree (path , src , len , dst , crlf_action );
800801 if (ret ) {
801802 src = dst -> buf ;
802803 len = dst -> len ;
0 commit comments