diff options
| author | Edward Thomson <ethomson@microsoft.com> | 2013-02-27 14:47:39 -0600 |
|---|---|---|
| committer | Edward Thomson <ethomson@microsoft.com> | 2013-02-27 15:35:52 -0600 |
| commit | 395509ffcd5007d8fa9ecccdf2090c5ed24c00e6 (patch) | |
| tree | 759a4fedeb4ebacff0aff57a02240ca7b54b8fa3 /tests-clar/checkout/tree.c | |
| parent | 69903777862bfdb03855ec13b0b63d65e0ed5410 (diff) | |
| download | libgit2-395509ffcd5007d8fa9ecccdf2090c5ed24c00e6.tar.gz | |
don't dereference at the end of the workdir iterator
Diffstat (limited to 'tests-clar/checkout/tree.c')
| -rw-r--r-- | tests-clar/checkout/tree.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c index 821cbfe0e..348be51a8 100644 --- a/tests-clar/checkout/tree.c +++ b/tests-clar/checkout/tree.c @@ -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); +} |
