diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2023-03-03 04:38:10 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-03 04:38:10 -0800 |
commit | 8164b4816230711f1aeb8e474011f496f3bfdb98 (patch) | |
tree | 2394626b8348371bca263ea1e5808c140577eefc | |
parent | af12fc11c520b58fe548a5ff736812462c269685 (diff) | |
parent | 129cadf9bf9ef1b43dd844d54f2b57a52b69ed2a (diff) | |
download | libgit2-8164b4816230711f1aeb8e474011f496f3bfdb98.tar.gz |
Merge pull request #6521 from libgit2/ethomson/weird_ignore
-rw-r--r-- | src/libgit2/index.c | 3 | ||||
-rw-r--r-- | tests/libgit2/index/addall.c | 46 |
2 files changed, 48 insertions, 1 deletions
diff --git a/src/libgit2/index.c b/src/libgit2/index.c index 195ec1d5a..d4532c005 100644 --- a/src/libgit2/index.c +++ b/src/libgit2/index.c @@ -3509,7 +3509,8 @@ static int index_apply_to_wd_diff(git_index *index, int action, const git_strarr GIT_DIFF_RECURSE_UNTRACKED_DIRS; if (flags == GIT_INDEX_ADD_FORCE) - opts.flags |= GIT_DIFF_INCLUDE_IGNORED; + opts.flags |= GIT_DIFF_INCLUDE_IGNORED | + GIT_DIFF_RECURSE_IGNORED_DIRS; } if ((error = git_diff_index_to_workdir(&diff, repo, index, &opts)) < 0) diff --git a/tests/libgit2/index/addall.c b/tests/libgit2/index/addall.c index 6f95f6386..e76b6e81d 100644 --- a/tests/libgit2/index/addall.c +++ b/tests/libgit2/index/addall.c @@ -441,6 +441,52 @@ void test_index_addall__callback_filtering(void) git_index_free(index); } +void test_index_addall__handles_ignored_files_in_directory(void) +{ + git_index *index; + + g_repo = cl_git_sandbox_init_new(TEST_DIR); + + cl_git_mkfile(TEST_DIR "/file.foo", "a file"); + cl_git_mkfile(TEST_DIR "/file.bar", "another file"); + cl_must_pass(p_mkdir(TEST_DIR "/folder", 0777)); + cl_git_mkfile(TEST_DIR "/folder/asdf", "yet another file"); + + cl_git_mkfile(TEST_DIR "/.gitignore", "folder/\n"); + + check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0); + + cl_git_pass(git_repository_index(&index, g_repo)); + cl_git_pass(git_index_add_all(index, NULL, 0, NULL, NULL)); + + check_status(g_repo, 3, 0, 0, 0, 0, 0, 1, 0); + + git_index_free(index); +} + +void test_index_addall__force_adds_ignored_directories(void) +{ + git_index *index; + + g_repo = cl_git_sandbox_init_new(TEST_DIR); + + cl_git_mkfile(TEST_DIR "/file.foo", "a file"); + cl_git_mkfile(TEST_DIR "/file.bar", "another file"); + cl_must_pass(p_mkdir(TEST_DIR "/folder", 0777)); + cl_git_mkfile(TEST_DIR "/folder/asdf", "yet another file"); + + cl_git_mkfile(TEST_DIR "/.gitignore", "folder/\n"); + + check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0); + + cl_git_pass(git_repository_index(&index, g_repo)); + cl_git_pass(git_index_add_all(index, NULL, GIT_INDEX_ADD_FORCE, NULL, NULL)); + + check_status(g_repo, 4, 0, 0, 0, 0, 0, 0, 0); + + git_index_free(index); +} + void test_index_addall__adds_conflicts(void) { git_index *index; |