diff options
| author | Sven Strickroth <email@cs-ware.de> | 2013-03-07 22:15:40 +0100 |
|---|---|---|
| committer | Russell Belfer <rb@github.com> | 2013-03-25 14:03:16 -0700 |
| commit | b8acb775e25c76f07dac8855ad0a88b37f7b2f17 (patch) | |
| tree | f7e8d173813745f2a56c6078897fb9aeb9cad479 /tests-clar/checkout | |
| parent | 9733e80c2ae7517f44c658cd2914d99454470dd1 (diff) | |
| download | libgit2-b8acb775e25c76f07dac8855ad0a88b37f7b2f17.tar.gz | |
Added some tests for issue #1397
Signed-off-by: Sven Strickroth <email@cs-ware.de>
Diffstat (limited to 'tests-clar/checkout')
| -rw-r--r-- | tests-clar/checkout/crlf.c | 8 | ||||
| -rw-r--r-- | tests-clar/checkout/index.c | 17 | ||||
| -rw-r--r-- | tests-clar/checkout/tree.c | 34 |
3 files changed, 59 insertions, 0 deletions
diff --git a/tests-clar/checkout/crlf.c b/tests-clar/checkout/crlf.c index 74da27652..39889a181 100644 --- a/tests-clar/checkout/crlf.c +++ b/tests-clar/checkout/crlf.c @@ -35,6 +35,7 @@ void test_checkout_crlf__detect_crlf_autocrlf_false(void) git_checkout_head(g_repo, &opts); test_file_contents("./crlf/all-lf", ALL_LF_TEXT_RAW); + test_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW); #endif } @@ -55,6 +56,9 @@ void test_checkout_crlf__autocrlf_false_index_size_is_unfiltered_size(void) cl_assert((entry = git_index_get_bypath(index, "all-lf", 0)) != NULL); cl_assert(entry->file_size == strlen(ALL_LF_TEXT_RAW)); + cl_assert((entry = git_index_get_bypath(index, "all-crlf", 0)) != NULL); + cl_assert(entry->file_size == strlen(ALL_CRLF_TEXT_RAW)); + git_index_free(index); #endif } @@ -70,6 +74,7 @@ void test_checkout_crlf__detect_crlf_autocrlf_true(void) git_checkout_head(g_repo, &opts); test_file_contents("./crlf/all-lf", ALL_LF_TEXT_AS_CRLF); + test_file_contents("./crlf/all-crlf", ALL_CRLF_TEXT_RAW); #endif } @@ -90,6 +95,9 @@ void test_checkout_crlf__autocrlf_true_index_size_is_filtered_size(void) cl_assert((entry = git_index_get_bypath(index, "all-lf", 0)) != NULL); cl_assert(entry->file_size == strlen(ALL_LF_TEXT_AS_CRLF)); + cl_assert((entry = git_index_get_bypath(index, "all-crlf", 0)) != NULL); + cl_assert(entry->file_size == strlen(ALL_CRLF_TEXT_RAW)); + git_index_free(index); #endif } diff --git a/tests-clar/checkout/index.c b/tests-clar/checkout/index.c index 3976dd20e..6dfa95dd3 100644 --- a/tests-clar/checkout/index.c +++ b/tests-clar/checkout/index.c @@ -488,3 +488,20 @@ void test_checkout_index__can_checkout_a_newly_initialized_repository(void) cl_git_pass(git_checkout_index(g_repo, NULL, NULL)); } + +void test_checkout_index__issue_1397(void) +{ + git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT; + + test_checkout_index__cleanup(); + + g_repo = cl_git_sandbox_init("issue_1397"); + + set_core_autocrlf_to(true); + + opts.checkout_strategy = GIT_CHECKOUT_FORCE; + + cl_git_pass(git_checkout_index(g_repo, NULL, &opts)); + + test_file_contents("./issue_1397/crlf_file.txt", "first line\r\nsecond line\r\nboth with crlf"); +} 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); +} |
