diff options
| author | Russell Belfer <rb@github.com> | 2013-03-22 14:52:29 -0700 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-03-25 14:03:16 -0700 |
| commit | 1098cfaecae823ede02881f995f18aee2908b89f (patch) | |
| tree | 22699f76e42c99732c72a453cf5e716588af1525 /tests-clar/checkout/tree.c | |
| parent | b8acb775e25c76f07dac8855ad0a88b37f7b2f17 (diff) | |
| download | libgit2-1098cfaecae823ede02881f995f18aee2908b89f.tar.gz | |
Test fixes and cleanup
This fixes some places where the new tests were leaving the test
area in a bad state or were freeing data they should not free.
It also removes code that is extraneous to the core issue and
fixes an invalid SHA being looked up in one of the tests (which
was failing, but for the wrong reason).
Diffstat (limited to 'tests-clar/checkout/tree.c')
| -rw-r--r-- | tests-clar/checkout/tree.c | 25 |
1 files changed, 7 insertions, 18 deletions
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c index 0f0ac6982..2a8fbc457 100644 --- a/tests-clar/checkout/tree.c +++ b/tests-clar/checkout/tree.c @@ -485,33 +485,22 @@ void test_checkout_tree__can_checkout_with_last_workdir_item_missing(void) void test_checkout_tree__issue_1397(void) { git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; - git_config *cfg; const char *partial_oid = "8a7ef04"; - size_t len = strlen(partial_oid); - git_oid oid; - git_object *obj = NULL; - git_tree *tree = NULL; + git_object *tree = NULL; + + test_checkout_tree__cleanup(); /* cleanup default checkout */ g_repo = cl_git_sandbox_init("issue_1397"); - cl_git_pass(git_repository_config(&cfg, g_repo)); - cl_git_pass(git_config_set_bool(cfg, "core.autocrlf", true)); - git_config_free(cfg); + cl_repo_set_bool(g_repo, "core.autocrlf", true); - if (git_oid_fromstrn(&oid, partial_oid, len) == 0) - git_object_lookup_prefix(&obj, g_repo, &oid, len, GIT_OBJ_ANY); - cl_assert(obj); - cl_assert(git_object_type(obj) == GIT_OBJ_COMMIT); - cl_git_pass(git_commit_tree(&tree, (git_commit *)obj)); - git_object_free(obj); + cl_git_pass(git_revparse_single(&tree, g_repo, partial_oid)); opts.checkout_strategy = GIT_CHECKOUT_FORCE; - cl_assert(tree != NULL); - - git_checkout_tree(g_repo, (git_object *)tree, &opts); + cl_git_pass(git_checkout_tree(g_repo, tree, &opts)); test_file_contents("./issue_1397/crlf_file.txt", "first line\r\nsecond line\r\nboth with crlf"); - git_tree_free(tree); + git_object_free(tree); } |
