summaryrefslogtreecommitdiff
path: root/builtin/check-attr.c
diff options
context:
space:
mode:
authorJay Soffian <jaysoffian@gmail.com>2011-09-22 21:44:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-09-22 23:38:22 (GMT)
commitb2b3e9c2d623359ed680a5eef850ef2fd313b73c (patch)
tree8a8417ac565eba8fd0776367375e73d230597ed5 /builtin/check-attr.c
parent167a5800cb707ed489c3cb88174ee21e95a610ae (diff)
downloadgit-b2b3e9c2d623359ed680a5eef850ef2fd313b73c.zip
git-b2b3e9c2d623359ed680a5eef850ef2fd313b73c.tar.gz
git-b2b3e9c2d623359ed680a5eef850ef2fd313b73c.tar.bz2
Teach '--cached' option to check-attr
This option causes check-attr to consider .gitattributes only from the index, ignoring .gitattributes from the working tree. This allows the command to be used in situations where a working tree does not exist. Signed-off-by: Jay Soffian <jaysoffian@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/check-attr.c')
-rw-r--r--builtin/check-attr.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 708988a..ded0d83 100644
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
@@ -5,6 +5,7 @@
#include "parse-options.h"
static int all_attrs;
+static int cached_attrs;
static int stdin_paths;
static const char * const check_attr_usage[] = {
"git check-attr [-a | --all | attr...] [--] pathname...",
@@ -16,6 +17,7 @@ static int null_term_line;
static const struct option check_attr_options[] = {
OPT_BOOLEAN('a', "all", &all_attrs, "report all attributes set on file"),
+ OPT_BOOLEAN(0, "cached", &cached_attrs, "use .gitattributes only from the index"),
OPT_BOOLEAN(0 , "stdin", &stdin_paths, "read file names from stdin"),
OPT_BOOLEAN('z', NULL, &null_term_line,
"input paths are terminated by a null character"),
@@ -99,6 +101,9 @@ int cmd_check_attr(int argc, const char **argv, const char *prefix)
die("invalid cache");
}
+ if (cached_attrs)
+ git_attr_set_direction(GIT_ATTR_INDEX, NULL);
+
doubledash = -1;
for (i = 0; doubledash < 0 && i < argc; i++) {
if (!strcmp(argv[i], "--"))