summaryrefslogtreecommitdiff
path: root/tests-clar/checkout/tree.c
diff options
context:
space:
mode:
authorSven Strickroth <email@cs-ware.de>2013-03-07 22:15:40 +0100
committerRussell Belfer <rb@github.com>2013-03-25 14:03:16 -0700
commitb8acb775e25c76f07dac8855ad0a88b37f7b2f17 (patch)
treef7e8d173813745f2a56c6078897fb9aeb9cad479 /tests-clar/checkout/tree.c
parent9733e80c2ae7517f44c658cd2914d99454470dd1 (diff)
downloadlibgit2-b8acb775e25c76f07dac8855ad0a88b37f7b2f17.tar.gz
Added some tests for issue #1397
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Diffstat (limited to 'tests-clar/checkout/tree.c')
-rw-r--r--tests-clar/checkout/tree.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests-clar/checkout/tree.c b/tests-clar/checkout/tree.c
index 8309cd721..0f0ac6982 100644
--- a/tests-clar/checkout/tree.c
+++ b/tests-clar/checkout/tree.c
@@ -481,3 +481,37 @@ void test_checkout_tree__can_checkout_with_last_workdir_item_missing(void)
git_commit_free(commit);
git_index_free(index);
}
+
+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;
+
+ 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);
+
+ 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);
+
+ opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
+ cl_assert(tree != NULL);
+
+ git_checkout_tree(g_repo, (git_object *)tree, &opts);
+
+ test_file_contents("./issue_1397/crlf_file.txt", "first line\r\nsecond line\r\nboth with crlf");
+
+ git_tree_free(tree);
+}