12
12
* translation when the "text" attribute or "auto_crlf" option is set.
13
13
*/
14
14
15
- enum action {
15
+ enum crlf_action {
16
16
CRLF_GUESS = -1 ,
17
17
CRLF_BINARY = 0 ,
18
18
CRLF_TEXT ,
@@ -94,9 +94,9 @@ static int is_binary(unsigned long size, struct text_stat *stats)
94
94
return 0 ;
95
95
}
96
96
97
- static enum eol determine_output_conversion (enum action action )
97
+ static enum eol output_eol (enum crlf_action crlf_action )
98
98
{
99
- switch (action ) {
99
+ switch (crlf_action ) {
100
100
case CRLF_BINARY :
101
101
return EOL_UNSET ;
102
102
case CRLF_CRLF :
@@ -119,13 +119,13 @@ static enum eol determine_output_conversion(enum action action)
119
119
return core_eol ;
120
120
}
121
121
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 ,
123
123
struct text_stat * stats , enum safe_crlf checksafe )
124
124
{
125
125
if (!checksafe )
126
126
return ;
127
127
128
- if (determine_output_conversion ( action ) == EOL_LF ) {
128
+ if (output_eol ( crlf_action ) == EOL_LF ) {
129
129
/*
130
130
* CRLFs would not be restored by checkout:
131
131
* check if we'd remove CRLFs
@@ -136,7 +136,7 @@ static void check_safe_crlf(const char *path, enum action action,
136
136
else /* i.e. SAFE_CRLF_FAIL */
137
137
die ("CRLF would be replaced by LF in %s." , path );
138
138
}
139
- } else if (determine_output_conversion ( action ) == EOL_CRLF ) {
139
+ } else if (output_eol ( crlf_action ) == EOL_CRLF ) {
140
140
/*
141
141
* CRLFs would be added by checkout:
142
142
* check if we have "naked" LFs
@@ -188,18 +188,19 @@ static int has_cr_in_index(const char *path)
188
188
}
189
189
190
190
static 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 )
192
193
{
193
194
struct text_stat stats ;
194
195
char * dst ;
195
196
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 )
198
199
return 0 ;
199
200
200
201
gather_stats (src , len , & stats );
201
202
202
- if (action == CRLF_AUTO || action == CRLF_GUESS ) {
203
+ if (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS ) {
203
204
/*
204
205
* We're currently not going to even try to convert stuff
205
206
* 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,
214
215
if (is_binary (len , & stats ))
215
216
return 0 ;
216
217
217
- if (action == CRLF_GUESS ) {
218
+ if (crlf_action == CRLF_GUESS ) {
218
219
/*
219
220
* If the file in the index has any CR in it, do not convert.
220
221
* 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,
224
225
}
225
226
}
226
227
227
- check_safe_crlf (path , action , & stats , checksafe );
228
+ check_safe_crlf (path , crlf_action , & stats , checksafe );
228
229
229
230
/* Optimization: No CR? Nothing to convert, regardless. */
230
231
if (!stats .cr )
@@ -234,7 +235,7 @@ static int crlf_to_git(const char *path, const char *src, size_t len,
234
235
if (strbuf_avail (buf ) + buf -> len < len )
235
236
strbuf_grow (buf , len - buf -> len );
236
237
dst = buf -> buf ;
237
- if (action == CRLF_AUTO || action == CRLF_GUESS ) {
238
+ if (crlf_action == CRLF_AUTO || crlf_action == CRLF_GUESS ) {
238
239
/*
239
240
* If we guessed, we already know we rejected a file with
240
241
* 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,
257
258
}
258
259
259
260
static 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 )
261
262
{
262
263
char * to_free = NULL ;
263
264
struct text_stat stats ;
264
265
265
- if (!len || determine_output_conversion ( action ) != EOL_CRLF )
266
+ if (!len || output_eol ( crlf_action ) != EOL_CRLF )
266
267
return 0 ;
267
268
268
269
gather_stats (src , len , & stats );
@@ -275,8 +276,8 @@ static int crlf_to_worktree(const char *path, const char *src, size_t len,
275
276
if (stats .lf == stats .crlf )
276
277
return 0 ;
277
278
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 ) {
280
281
/* If we have any CR or CRLF line endings, we do not touch it */
281
282
/* This is the new safer autocrlf-handling */
282
283
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)
715
716
return !!ATTR_TRUE (value );
716
717
}
717
718
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 )
719
720
{
720
721
if (text_attr == CRLF_BINARY )
721
722
return CRLF_BINARY ;
@@ -730,17 +731,17 @@ int convert_to_git(const char *path, const char *src, size_t len,
730
731
struct strbuf * dst , enum safe_crlf checksafe )
731
732
{
732
733
struct git_attr_check check [5 ];
733
- enum action action = CRLF_GUESS ;
734
+ enum crlf_action crlf_action = CRLF_GUESS ;
734
735
enum eol eol_attr = EOL_UNSET ;
735
736
int ident = 0 , ret = 0 ;
736
737
const char * filter = NULL ;
737
738
738
739
setup_convert_check (check );
739
740
if (!git_checkattr (path , ARRAY_SIZE (check ), check )) {
740
741
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 );
744
745
ident = git_path_check_ident (path , check + 1 );
745
746
drv = git_path_check_convert (path , check + 2 );
746
747
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,
753
754
src = dst -> buf ;
754
755
len = dst -> len ;
755
756
}
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 );
758
759
if (ret ) {
759
760
src = dst -> buf ;
760
761
len = dst -> len ;
@@ -767,17 +768,17 @@ static int convert_to_working_tree_internal(const char *path, const char *src,
767
768
int normalizing )
768
769
{
769
770
struct git_attr_check check [5 ];
770
- enum action action = CRLF_GUESS ;
771
+ enum crlf_action crlf_action = CRLF_GUESS ;
771
772
enum eol eol_attr = EOL_UNSET ;
772
773
int ident = 0 , ret = 0 ;
773
774
const char * filter = NULL ;
774
775
775
776
setup_convert_check (check );
776
777
if (!git_checkattr (path , ARRAY_SIZE (check ), check )) {
777
778
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 );
781
782
ident = git_path_check_ident (path , check + 1 );
782
783
drv = git_path_check_convert (path , check + 2 );
783
784
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,
795
796
* is a smudge filter. The filter might expect CRLFs.
796
797
*/
797
798
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 );
800
801
if (ret ) {
801
802
src = dst -> buf ;
802
803
len = dst -> len ;
0 commit comments