Commit cb76eed5 by Edward Thomson Committed by GitHub

Merge pull request #4054 from jfultz/jfultz/fix_GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH

Fix handling of GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH flag.
parents 2854e619 5f959dca
......@@ -2553,6 +2553,10 @@ int git_checkout_iterator(
GIT_ITERATOR_IGNORE_CASE : GIT_ITERATOR_DONT_IGNORE_CASE;
baseline_opts.start = data.pfx;
baseline_opts.end = data.pfx;
if (opts && (opts->checkout_strategy & GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH)) {
baseline_opts.pathlist.count = opts->paths.count;
baseline_opts.pathlist.strings = opts->paths.strings;
}
if (data.opts.baseline_index) {
if ((error = git_iterator_for_index(
......
......@@ -422,6 +422,44 @@ void test_checkout_tree__can_checkout_with_pattern(void)
cl_assert(git_path_exists("testrepo/new.txt"));
}
void test_checkout_tree__pathlist_checkout_ignores_non_matches(void)
{
char *entries[] = { "branch_file.txt", "link_to_new.txt" };
/* reset to beginning of history (i.e. just a README file) */
g_opts.checkout_strategy =
GIT_CHECKOUT_FORCE | GIT_CHECKOUT_REMOVE_UNTRACKED;
cl_git_pass(git_revparse_single(&g_object, g_repo, "refs/heads/master"));
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/master"));
cl_assert(git_path_exists("testrepo/README"));
cl_assert(git_path_exists("testrepo/branch_file.txt"));
cl_assert(git_path_exists("testrepo/link_to_new.txt"));
cl_assert(git_path_exists("testrepo/new.txt"));
cl_git_pass(git_revparse_single(&g_object, g_repo, "8496071c1b46c854b31185ea97743be6a8774479"));
g_opts.checkout_strategy =
GIT_CHECKOUT_FORCE | GIT_CHECKOUT_DISABLE_PATHSPEC_MATCH;
g_opts.paths.strings = entries;
g_opts.paths.count = 2;
cl_git_pass(git_checkout_tree(g_repo, g_object, &g_opts));
cl_assert(git_path_exists("testrepo/README"));
cl_assert(!git_path_exists("testrepo/branch_file.txt"));
cl_assert(!git_path_exists("testrepo/link_to_new.txt"));
cl_assert(git_path_exists("testrepo/new.txt"));
git_object_free(g_object);
g_object = NULL;
}
void test_checkout_tree__can_disable_pattern_match(void)
{
char *entries[] = { "b*.txt" };
......
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