Fix funny types used in attribute value representation
It was bothering me a lot that I abused small integer values casted to (void *) to represent non string values in gitattributes. This corrects it by making the type of attribute values (const char *), and using the address of a few statically allocated character buffer to denote true/false. Unset attributes are represented as having NULLs as their values. Added in-header documentation to explain how git_checkattr() routine should be called. Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
@ -42,7 +42,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
|
||||
if (git_checkattr(argv[i], cnt, check))
|
||||
die("git_checkattr died");
|
||||
for (j = 0; j < cnt; j++) {
|
||||
void *value = check[j].value;
|
||||
const char *value = check[j].value;
|
||||
|
||||
if (ATTR_TRUE(value))
|
||||
value = "set";
|
||||
@ -52,7 +52,7 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
|
||||
value = "unspecified";
|
||||
|
||||
write_name_quoted("", 0, argv[i], 1, stdout);
|
||||
printf(": %s: %s\n", argv[j+1], (char *) value);
|
||||
printf(": %s: %s\n", argv[j+1], value);
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user