6 static const char check_attr_usage[] =
7 "git check-attr attr... [--] pathname...";
9 static void check_attr(int cnt, struct git_attr_check *check,
10 const char** name, const char *file)
13 if (git_checkattr(file, cnt, check))
14 die("git_checkattr died");
15 for (j = 0; j < cnt; j++) {
16 const char *value = check[j].value;
20 else if (ATTR_FALSE(value))
22 else if (ATTR_UNSET(value))
23 value = "unspecified";
25 quote_c_style(file, NULL, stdout, 0);
26 printf(": %s: %s\n", name[j], value);
30 int cmd_check_attr(int argc, const char **argv, const char *prefix)
32 struct git_attr_check *check;
33 int cnt, i, doubledash;
35 if (read_cache() < 0) {
40 for (i = 1; doubledash < 0 && i < argc; i++) {
41 if (!strcmp(argv[i], "--"))
45 /* If there is no double dash, we handle only one attribute */
53 if (cnt <= 0 || argc < doubledash)
54 usage(check_attr_usage);
55 check = xcalloc(cnt, sizeof(*check));
56 for (i = 0; i < cnt; i++) {
60 a = git_attr(name, strlen(name));
62 return error("%s: not a valid attribute name", name);
66 for (i = doubledash; i < argc; i++)
67 check_attr(cnt, check, argv+1, argv[i]);
68 maybe_flush_or_die(stdout, "attribute to stdout");