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 <tboegi@web.de> Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin Ågren committed
Aug 21, 2017 at 19:43 UTC
5c94c93d504e29c2099200a68926a34072cf2736
1 file changed
+3
-2
convert.c
+3
-2
@@ -1012,7 +1012,6 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)
1012
ca->crlf_action = git_path_check_crlf(ccheck + 4);
1013
if (ca->crlf_action == CRLF_UNDEFINED)
1014
ca->crlf_action = git_path_check_crlf(ccheck + 0);
1015
- ca->attr_action = ca->crlf_action;
1015
ca->ident = git_path_check_ident(ccheck + 1);
1016
ca->drv = git_path_check_convert(ccheck + 2);
1017
if (ca->crlf_action != CRLF_BINARY) {
@@ -1026,12 +1025,14 @@ static void convert_attrs(struct conv_attrs *ca, const char *path)
1025
else if (eol_attr == EOL_CRLF)
1026
ca->crlf_action = CRLF_TEXT_CRLF;
1027
}
1029
- ca->attr_action = ca->crlf_action;
1028
} else {
1029
ca->drv = NULL;
1030
ca->crlf_action = CRLF_UNDEFINED;
1031
ca->ident = 0;
1032
}
1033
+
1034
+ /* Save attr and make a decision for action */
1035
+ ca->attr_action = ca->crlf_action;
1036
if (ca->crlf_action == CRLF_TEXT)
1037
ca->crlf_action = text_eol_is_crlf() ? CRLF_TEXT_CRLF : CRLF_TEXT_INPUT;
1038
if (ca->crlf_action == CRLF_UNDEFINED && auto_crlf == AUTO_CRLF_FALSE)