summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 167a580)
raw | patch | inline | side by side (parent: 167a580)
author | Jay Soffian <jaysoffian@gmail.com> | |
Thu, 22 Sep 2011 21:44:20 +0000 (17:44 -0400) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Thu, 22 Sep 2011 23:38:22 +0000 (16:38 -0700) |
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>
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>
Documentation/git-check-attr.txt | patch | blob | history | |
builtin/check-attr.c | patch | blob | history | |
t/t0003-attributes.sh | patch | blob | history |
index 1f7312a1895ae66901e5472132406d01303da1f8..5abdbaa51cf58e216bbc63d28039a5abfba01669 100644 (file)
paths. If this option is used, then 'unspecified' attributes
will not be included in the output.
+--cached::
+ Consider `.gitattributes` in the index only, ignoring the working tree.
+
--stdin::
Read file names from stdin instead of from the command-line.
diff --git a/builtin/check-attr.c b/builtin/check-attr.c
index 708988a0e1a318fb737624f489d01e0686cd0611..ded0d836d39d101f7879fecb11e7057a006c1b17 100644 (file)
--- a/builtin/check-attr.c
+++ b/builtin/check-attr.c
#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...",
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"),
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], "--"))
diff --git a/t/t0003-attributes.sh b/t/t0003-attributes.sh
index ae2f1da28fa55b92338d7dbcb6ef851b6ec40118..c0a45630be7204fde75632a5abea8f9aeda9f13d 100755 (executable)
--- a/t/t0003-attributes.sh
+++ b/t/t0003-attributes.sh
test_expect_success 'attribute test: --all option' '
- grep -v unspecified < expect-all | sort > expect &&
- sed -e "s/:.*//" < expect-all | uniq |
- git check-attr --stdin --all | sort > actual &&
- test_cmp expect actual
+ grep -v unspecified <expect-all | sort >specified-all &&
+ sed -e "s/:.*//" <expect-all | uniq >stdin-all &&
+ git check-attr --stdin --all <stdin-all | sort >actual &&
+ test_cmp specified-all actual
+'
+
+test_expect_success 'attribute test: --cached option' '
+
+ : >empty &&
+ git check-attr --cached --stdin --all <stdin-all | sort >actual &&
+ test_cmp empty actual &&
+ git add .gitattributes a/.gitattributes a/b/.gitattributes &&
+ git check-attr --cached --stdin --all <stdin-all | sort >actual &&
+ test_cmp specified-all actual
'
test_expect_success 'root subdir attribute test' '
'
+test_expect_success 'bare repository: check that --cached honors index' '
+ GIT_INDEX_FILE=../.git/index \
+ git check-attr --cached --stdin --all <../stdin-all |
+ sort >actual &&
+ test_cmp ../specified-all actual
+'
+
test_expect_success 'bare repository: test info/attributes' '
(