Skip to content

Commit 309befe

Browse files
author
Edward Thomson
committed
index: test git_index_add_all with force
Ensure that when all files beneath a directory are ignored that we add the files when FORCE is specified.
1 parent 6fb5ab3 commit 309befe

1 file changed

Lines changed: 23 additions & 0 deletions

File tree

tests/libgit2/index/addall.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,29 @@ void test_index_addall__handles_ignored_files_in_directory(void)
464464
git_index_free(index);
465465
}
466466

467+
void test_index_addall__force_adds_ignored_directories(void)
468+
{
469+
git_index *index;
470+
471+
g_repo = cl_git_sandbox_init_new(TEST_DIR);
472+
473+
cl_git_mkfile(TEST_DIR "/file.foo", "a file");
474+
cl_git_mkfile(TEST_DIR "/file.bar", "another file");
475+
cl_must_pass(p_mkdir(TEST_DIR "/folder", 0777));
476+
cl_git_mkfile(TEST_DIR "/folder/asdf", "yet another file");
477+
478+
cl_git_mkfile(TEST_DIR "/.gitignore", "folder/\n");
479+
480+
check_status(g_repo, 0, 0, 0, 3, 0, 0, 1, 0);
481+
482+
cl_git_pass(git_repository_index(&index, g_repo));
483+
cl_git_pass(git_index_add_all(index, NULL, GIT_INDEX_ADD_FORCE, NULL, NULL));
484+
485+
check_status(g_repo, 4, 0, 0, 0, 0, 0, 0, 0);
486+
487+
git_index_free(index);
488+
}
489+
467490
void test_index_addall__adds_conflicts(void)
468491
{
469492
git_index *index;

0 commit comments

Comments
 (0)