5 static const char check_attr_usage[] =
6 "git-check-attr attr... [--] pathname...";
8 int cmd_check_attr(int argc, const char **argv, const char *prefix)
10 struct git_attr_check *check;
11 int cnt, i, doubledash;
14 for (i = 1; doubledash < 0 && i < argc; i++) {
15 if (!strcmp(argv[i], "--"))
19 /* If there is no double dash, we handle only one attribute */
27 if (cnt <= 0 || argc < doubledash)
28 usage(check_attr_usage);
29 check = xcalloc(cnt, sizeof(*check));
30 for (i = 0; i < cnt; i++) {
34 a = git_attr(name, strlen(name));
36 return error("%s: not a valid attribute name", name);
40 for (i = doubledash; i < argc; i++) {
42 if (git_checkattr(argv[i], cnt, check))
43 die("git_checkattr died");
44 for (j = 0; j < cnt; j++) {
45 const char *value = check[j].value;
49 else if (ATTR_FALSE(value))
51 else if (ATTR_UNSET(value))
52 value = "unspecified";
54 write_name_quoted("", 0, argv[i], 1, stdout);
55 printf(": %s: %s\n", argv[j+1], value);