Merge pull request #3146 from ethomson/add_untracked_files index_add_all: include untracked files in new subdirs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
diff --git a/src/index.c b/src/index.c
index 8f0976d..561fe73 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 f13b768..377d207 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)
{