6 static const char check_attr_usage[] =
7 "git-check-attr attr... [--] pathname...";
9 int cmd_check_attr(int argc, const char **argv, const char *prefix)
11 struct git_attr_check *check;
12 int cnt, i, doubledash;
14 if (read_cache() < 0) {
19 for (i = 1; doubledash < 0 && i < argc; i++) {
20 if (!strcmp(argv[i], "--"))
24 /* If there is no double dash, we handle only one attribute */
32 if (cnt <= 0 || argc < doubledash)
33 usage(check_attr_usage);
34 check = xcalloc(cnt, sizeof(*check));
35 for (i = 0; i < cnt; i++) {
39 a = git_attr(name, strlen(name));
41 return error("%s: not a valid attribute name", name);
45 for (i = doubledash; i < argc; i++) {
47 if (git_checkattr(argv[i], cnt, check))
48 die("git_checkattr died");
49 for (j = 0; j < cnt; j++) {
50 const char *value = check[j].value;
54 else if (ATTR_FALSE(value))
56 else if (ATTR_UNSET(value))
57 value = "unspecified";
59 quote_c_style(argv[i], NULL, stdout, 0);
60 printf(": %s: %s\n", argv[j+1], value);