diff options
-rw-r--r-- | src/ignore.c | 1 | ||||
-rw-r--r-- | src/index.c | 4 | ||||
-rw-r--r-- | tests/index/addall.c | 23 | ||||
-rw-r--r-- | tests/status/ignore.c | 12 |
4 files changed, 39 insertions, 1 deletions
diff --git a/src/ignore.c b/src/ignore.c index 7ad8500e8..0031e4696 100644 --- a/src/ignore.c +++ b/src/ignore.c @@ -80,6 +80,7 @@ static int does_negate_rule(int *out, git_vector *rules, git_attr_fnmatch *match git_vector_foreach(rules, i, rule) { if (!(rule->flags & GIT_ATTR_FNMATCH_HASWILD)) { if (does_negate_pattern(rule, match)) { + error = 0; *out = 1; goto out; } diff --git a/src/index.c b/src/index.c index 8f0976d13..561fe73c4 100644 --- a/src/index.c +++ b/src/index.c @@ -2683,7 +2683,9 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr opts.flags = GIT_DIFF_INCLUDE_TYPECHANGE; if (action == INDEX_ACTION_ADDALL) { - opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | GIT_DIFF_RECURSE_IGNORED_DIRS; + opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED | + GIT_DIFF_RECURSE_UNTRACKED_DIRS; + if (flags == GIT_INDEX_ADD_FORCE) opts.flags |= GIT_DIFF_INCLUDE_IGNORED; } diff --git a/tests/index/addall.c b/tests/index/addall.c index f13b768ce..377d2079e 100644 --- a/tests/index/addall.c +++ b/tests/index/addall.c @@ -282,6 +282,29 @@ void test_index_addall__repo_lifecycle(void) git_index_free(index); } +void test_index_addall__files_in_folders(void) +{ + git_index *index; + git_strarray paths = { NULL, 0 }; + + addall_create_test_repo(true); + + cl_git_pass(git_repository_index(&index, g_repo)); + + cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL)); + check_stat_data(index, TEST_DIR "/file.bar", true); + check_status(g_repo, 2, 0, 0, 0, 0, 0, 1); + + cl_must_pass(p_mkdir(TEST_DIR "/subdir", 0777)); + cl_git_mkfile(TEST_DIR "/subdir/file", "hello!\n"); + check_status(g_repo, 2, 0, 0, 1, 0, 0, 1); + + cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL)); + check_status(g_repo, 3, 0, 0, 0, 0, 0, 1); + + git_index_free(index); +} + static int addall_match_prefix( const char *path, const char *matched_pathspec, void *payload) { diff --git a/tests/status/ignore.c b/tests/status/ignore.c index 3193d318e..ba1d69a99 100644 --- a/tests/status/ignore.c +++ b/tests/status/ignore.c @@ -1010,3 +1010,15 @@ void test_status_ignore__subdir_doesnt_match_above(void) cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, "src/SRC/test.txt")); cl_assert_equal_i(icase, ignored); } + +void test_status_ignore__negate_exact_previous(void) +{ + int ignored; + + g_repo = cl_git_sandbox_init("empty_standard_repo"); + + cl_git_mkfile("empty_standard_repo/.gitignore", "*.com\ntags\n!tags/\n.buildpath"); + cl_git_mkfile("empty_standard_repo/.buildpath", ""); + cl_git_pass(git_ignore_path_is_ignored(&ignored, g_repo, ".buildpath")); + cl_assert_equal_i(1, ignored); +} |