Skip to content

Commit 5c94c93

Browse files
Martin Ågrengitster
authored andcommitted
convert: always initialize attr_action in convert_attrs
convert_attrs contains an "if-else". In the "if", we set attr_action twice, and the first assignment has no effect. In the "else", we do not set it at all. Since git_check_attr always returns the same value, we'll always end up in the "if", so there is no problem right now. But convert_attrs is obviously trying not to rely on such an implementation-detail of another component. Make the initialization of attr_action after the if-else. Remove the earlier assignments. Suggested-by: Torsten Bögershausen <[email protected]> Signed-off-by: Martin Ågren <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4d7268b commit 5c94c93

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

convert.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1012,7 +1012,6 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)
10121012
ca->crlf_action = git_path_check_crlf(ccheck + 4);
10131013
if (ca->crlf_action == CRLF_UNDEFINED)
10141014
ca->crlf_action = git_path_check_crlf(ccheck + 0);
1015-
ca->attr_action = ca->crlf_action;
10161015
ca->ident = git_path_check_ident(ccheck + 1);
10171016
ca->drv = git_path_check_convert(ccheck + 2);
10181017
if (ca->crlf_action != CRLF_BINARY) {
@@ -1026,12 +1025,14 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)
10261025
else if (eol_attr == EOL_CRLF)
10271026
ca->crlf_action = CRLF_TEXT_CRLF;
10281027
}
1029-
ca->attr_action = ca->crlf_action;
10301028
} else {
10311029
ca->drv = NULL;
10321030
ca->crlf_action = CRLF_UNDEFINED;
10331031
ca->ident = 0;
10341032
}
1033+
1034+
/* Save attr and make a decision for action */
1035+
ca->attr_action = ca->crlf_action;
10351036
if (ca->crlf_action == CRLF_TEXT)
10361037
ca->crlf_action = text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;
10371038
if (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_FALSE)

0 commit comments

Comments
 (0)