mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-08 18:08:11 +00:00
Merge pull request #1372 from ethomson/checkout_workdir_end
don't dereference at the end of the workdir iterator
This commit is contained in:
commit
9f9477d650
@ -475,6 +475,8 @@ static int checkout_action(
|
||||
/* case 2 - entry prefixed by workdir tree */
|
||||
if (git_iterator_advance_into_directory(workdir, &wd) < 0)
|
||||
goto fail;
|
||||
|
||||
*wditem_ptr = wd;
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -444,3 +444,41 @@ void test_checkout_tree__checking_out_a_conflicting_content_change_returns_EMERG
|
||||
|
||||
assert_conflict("branch_file.txt", "hello\n", "5b5b025", "c47800c");
|
||||
}
|
||||
|
||||
void test_checkout_tree__can_checkout_with_last_workdir_item_missing(void)
|
||||
{
|
||||
git_index *index = NULL;
|
||||
git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
|
||||
git_oid tree_id, commit_id;
|
||||
git_tree *tree = NULL;
|
||||
git_commit *commit = NULL;
|
||||
|
||||
git_repository_index(&index, g_repo);
|
||||
|
||||
opts.checkout_strategy = GIT_CHECKOUT_FORCE;
|
||||
|
||||
cl_git_pass(git_reference_name_to_id(&commit_id, g_repo, "refs/heads/master"));
|
||||
cl_git_pass(git_commit_lookup(&commit, g_repo, &commit_id));
|
||||
|
||||
cl_git_pass(git_checkout_tree(g_repo, (git_object *)commit, &opts));
|
||||
cl_git_pass(git_repository_set_head(g_repo, "refs/heads/master"));
|
||||
|
||||
|
||||
cl_git_pass(p_mkdir("./testrepo/this-is-dir", 0777));
|
||||
cl_git_mkfile("./testrepo/this-is-dir/contained_file", "content\n");
|
||||
|
||||
cl_git_pass(git_index_add_bypath(index, "this-is-dir/contained_file"));
|
||||
git_index_write_tree(&tree_id, index);
|
||||
cl_git_pass(git_tree_lookup(&tree, g_repo, &tree_id));
|
||||
|
||||
cl_git_pass(p_unlink("./testrepo/this-is-dir/contained_file"));
|
||||
|
||||
opts.checkout_strategy = GIT_CHECKOUT_SAFE;
|
||||
|
||||
opts.checkout_strategy = 1;
|
||||
git_checkout_tree(g_repo, (git_object *)tree, &opts);
|
||||
|
||||
git_tree_free(tree);
|
||||
git_commit_free(commit);
|
||||
git_index_free(index);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user