diff options
| author | Russell Belfer <rb@github.com> | 2012-05-03 16:37:25 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2012-05-03 16:37:25 -0700 |
| commit | f917481ee84cbba481c1854cccdedb2d98377d43 (patch) | |
| tree | b6276158b43f8d54358df5609fd0e508928306b2 /tests-clar/attr/file.c | |
| parent | 3fbcac89c47cb66ea193f66da6d93d1c36ed0f5e (diff) | |
| download | libgit2-f917481ee84cbba481c1854cccdedb2d98377d43.tar.gz | |
Support reading attributes from index
Depending on the operation, we need to consider gitattributes
in both the work dir and the index. This adds a parameter to
all of the gitattributes related functions that allows user
control of attribute reading behavior (i.e. prefer workdir,
prefer index, only use index).
This fix also covers allowing us to check attributes (and
hence do diff and status) on bare repositories.
This was a somewhat larger change that I hoped because it had
to change the cache key used for gitattributes files.
Diffstat (limited to 'tests-clar/attr/file.c')
| -rw-r--r-- | tests-clar/attr/file.c | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/tests-clar/attr/file.c b/tests-clar/attr/file.c index 4e1010230..d19708838 100644 --- a/tests-clar/attr/file.c +++ b/tests-clar/attr/file.c @@ -11,9 +11,9 @@ void test_attr_file__simple_read(void) git_attr_assignment *assign; git_attr_rule *rule; - cl_git_pass(git_attr_file__new(&file, NULL)); - cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr0"), file)); - cl_assert_equal_s(cl_fixture("attr/attr0"), file->path); + cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr0"))); + + cl_assert_equal_s(cl_fixture("attr/attr0"), file->key + 2); cl_assert(file->rules.length == 1); rule = get_rule(0); @@ -37,9 +37,9 @@ void test_attr_file__match_variants(void) git_attr_rule *rule; git_attr_assignment *assign; - cl_git_pass(git_attr_file__new(&file, NULL)); - cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr1"), file)); - cl_assert_equal_s(cl_fixture("attr/attr1"), file->path); + cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr1"))); + + cl_assert_equal_s(cl_fixture("attr/attr1"), file->key + 2); cl_assert(file->rules.length == 10); /* let's do a thorough check of this rule, then just verify @@ -123,9 +123,9 @@ void test_attr_file__assign_variants(void) git_attr_rule *rule; git_attr_assignment *assign; - cl_git_pass(git_attr_file__new(&file, NULL)); - cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr2"), file)); - cl_assert_equal_s(cl_fixture("attr/attr2"), file->path); + cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr2"))); + + cl_assert_equal_s(cl_fixture("attr/attr2"), file->key + 2); cl_assert(file->rules.length == 11); check_one_assign(file, 0, 0, "pat0", "simple", EXPECT_TRUE, NULL); @@ -189,9 +189,8 @@ void test_attr_file__check_attr_examples(void) git_attr_rule *rule; git_attr_assignment *assign; - cl_git_pass(git_attr_file__new(&file, NULL)); - cl_git_pass(git_attr_file__from_file(NULL, cl_fixture("attr/attr3"), file)); - cl_assert_equal_s(cl_fixture("attr/attr3"), file->path); + cl_git_pass(git_attr_file__new_and_load(&file, cl_fixture("attr/attr3"))); + cl_assert_equal_s(cl_fixture("attr/attr3"), file->key + 2); cl_assert(file->rules.length == 3); rule = get_rule(0); @@ -214,7 +213,7 @@ void test_attr_file__check_attr_examples(void) cl_assert(rule->assigns.length == 1); assign = get_assign(rule, 0); cl_assert_equal_s("myAttr", assign->name); - cl_assert(assign->value == NULL); + cl_assert(GIT_ATTR_UNSPECIFIED(assign->value)); rule = get_rule(2); cl_assert_equal_s("README", rule->match.pattern); |
