Skip to content

Commit f888185

Browse files
committed
ignore: adjust test for negating inside a dir
Given top !top/foo in an ignore file, we should not unignore top/foo. This is an implementation detail of the git code leaking, but that's the behaviour we should show. A negation rule can only negate an exact rule it has seen before.
1 parent 8de0f1e commit f888185

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

tests/status/ignore.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -751,27 +751,35 @@ void test_status_ignore__negative_ignores_inside_ignores(void)
751751
static const char *test_files[] = {
752752
"empty_standard_repo/top/mid/btm/tracked",
753753
"empty_standard_repo/top/mid/btm/untracked",
754+
"empty_standard_repo/zoo/bar",
755+
"empty_standard_repo/zoo/foo/bar",
754756
NULL
755757
};
756758

757759
make_test_data("empty_standard_repo", test_files);
758760
cl_git_mkfile(
759761
"empty_standard_repo/.gitignore",
760-
"top\n!top/mid/btm\n");
762+
"top\n"
763+
"!top/mid/btm\n"
764+
"zoo/*\n"
765+
"!zoo/bar\n"
766+
"!zoo/foo/bar\n");
761767
add_one_to_index("top/mid/btm/tracked");
762768

763769
{
764770
git_status_options opts = GIT_STATUS_OPTIONS_INIT;
765771
status_entry_counts counts;
766772
static const char *files[] = {
767773
".gitignore", "top/mid/btm/tracked", "top/mid/btm/untracked",
774+
"zoo/bar", "zoo/foo/bar",
768775
};
769776
static const unsigned int statuses[] = {
770-
GIT_STATUS_WT_NEW, GIT_STATUS_INDEX_NEW, GIT_STATUS_WT_NEW,
777+
GIT_STATUS_WT_NEW, GIT_STATUS_INDEX_NEW, GIT_STATUS_IGNORED,
778+
GIT_STATUS_WT_NEW, GIT_STATUS_IGNORED,
771779
};
772780

773781
memset(&counts, 0x0, sizeof(status_entry_counts));
774-
counts.expected_entry_count = 3;
782+
counts.expected_entry_count = 5;
775783
counts.expected_paths = files;
776784
counts.expected_statuses = statuses;
777785
opts.flags = GIT_STATUS_OPT_DEFAULTS |
@@ -785,6 +793,7 @@ void test_status_ignore__negative_ignores_inside_ignores(void)
785793
cl_assert_equal_i(0, counts.wrong_sorted_path);
786794
}
787795

788-
refute_is_ignored("top/mid/btm/tracked");
789-
refute_is_ignored("top/mid/btm/untracked");
796+
assert_is_ignored("top/mid/btm/tracked");
797+
assert_is_ignored("top/mid/btm/untracked");
798+
refute_is_ignored("foo/bar");
790799
}

0 commit comments

Comments
 (0)