Commit 39783719 by nulltoken

checkout: Mimic git_diff_options storage of paths

parent 5e4cb4f4
...@@ -39,7 +39,7 @@ typedef struct git_checkout_opts { ...@@ -39,7 +39,7 @@ typedef struct git_checkout_opts {
/* when not NULL, arrays of fnmatch pattern specifying /* when not NULL, arrays of fnmatch pattern specifying
* which paths should be taken into account * which paths should be taken into account
*/ */
git_strarray *paths; git_strarray paths;
} git_checkout_opts; } git_checkout_opts;
/** /**
......
...@@ -282,10 +282,8 @@ int git_checkout_index( ...@@ -282,10 +282,8 @@ int git_checkout_index(
diff_opts.flags = GIT_DIFF_INCLUDE_UNTRACKED; diff_opts.flags = GIT_DIFF_INCLUDE_UNTRACKED;
if (opts && opts->paths) { if (opts && opts->paths.count > 0)
diff_opts.pathspec.strings = opts->paths->strings; diff_opts.pathspec = opts->paths;
diff_opts.pathspec.count = opts->paths->count;
}
if ((error = git_diff_workdir_to_index(repo, &diff_opts, &diff)) < 0) if ((error = git_diff_workdir_to_index(repo, &diff_opts, &diff)) < 0)
goto cleanup; goto cleanup;
......
...@@ -102,12 +102,10 @@ void test_checkout_index__can_remove_untracked_files(void) ...@@ -102,12 +102,10 @@ void test_checkout_index__can_remove_untracked_files(void)
void test_checkout_index__honor_the_specified_pathspecs(void) void test_checkout_index__honor_the_specified_pathspecs(void)
{ {
git_strarray paths;
char *entries[] = { "*.txt" }; char *entries[] = { "*.txt" };
paths.strings = entries; g_opts.paths.strings = entries;
paths.count = 1; g_opts.paths.count = 1;
g_opts.paths = &paths;
cl_assert_equal_i(false, git_path_isfile("./testrepo/README")); cl_assert_equal_i(false, git_path_isfile("./testrepo/README"));
cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt")); cl_assert_equal_i(false, git_path_isfile("./testrepo/branch_file.txt"));
......
...@@ -32,12 +32,10 @@ void test_checkout_tree__cannot_checkout_a_non_treeish(void) ...@@ -32,12 +32,10 @@ void test_checkout_tree__cannot_checkout_a_non_treeish(void)
void test_checkout_tree__can_checkout_a_subdirectory_from_a_commit(void) void test_checkout_tree__can_checkout_a_subdirectory_from_a_commit(void)
{ {
git_strarray paths;
char *entries[] = { "ab/de/" }; char *entries[] = { "ab/de/" };
paths.strings = entries; g_opts.paths.strings = entries;
paths.count = 1; g_opts.paths.count = 1;
g_opts.paths = &paths;
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees")); cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees"));
...@@ -51,12 +49,10 @@ void test_checkout_tree__can_checkout_a_subdirectory_from_a_commit(void) ...@@ -51,12 +49,10 @@ void test_checkout_tree__can_checkout_a_subdirectory_from_a_commit(void)
void test_checkout_tree__can_checkout_a_subdirectory_from_a_subtree(void) void test_checkout_tree__can_checkout_a_subdirectory_from_a_subtree(void)
{ {
git_strarray paths;
char *entries[] = { "de/" }; char *entries[] = { "de/" };
paths.strings = entries; g_opts.paths.strings = entries;
paths.count = 1; g_opts.paths.count = 1;
g_opts.paths = &paths;
cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees:ab")); cl_git_pass(git_revparse_single(&g_object, g_repo, "subtrees:ab"));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment