]> git.proxmox.com Git - libgit2.git/blame - tests-clar/checkout/typechange.c
Fix some submodule and typechange checkout cases
[libgit2.git] / tests-clar / checkout / typechange.c
CommitLineData
0d64bef9
RB
1#include "clar_libgit2.h"
2#include "git2/checkout.h"
3#include "path.h"
4#include "posix.h"
5
6static git_repository *g_repo = NULL;
7
8static const char *g_typechange_oids[] = {
9 "79b9f23e85f55ea36a472a902e875bc1121a94cb",
10 "9bdb75b73836a99e3dbeea640a81de81031fdc29",
11 "0e7ed140b514b8cae23254cb8656fe1674403aff",
12 "9d0235c7a7edc0889a18f97a42ee6db9fe688447",
13 "9b19edf33a03a0c59cdfc113bfa5c06179bf9b1a",
14 "1b63caae4a5ca96f78e8dfefc376c6a39a142475",
15 "6eae26c90e8ccc4d16208972119c40635489c6f0",
16 NULL
17};
18
19static bool g_typechange_empty[] = {
20 true, false, false, false, false, false, true, true
21};
22
23void test_checkout_typechange__initialize(void)
24{
25 g_repo = cl_git_sandbox_init("typechanges");
26
27 cl_fixture_sandbox("submod2_target");
28 p_rename("submod2_target/.gitted", "submod2_target/.git");
29}
30
31void test_checkout_typechange__cleanup(void)
32{
33 cl_git_sandbox_cleanup();
34 cl_fixture_cleanup("submod2_target");
35}
36
37void test_checkout_typechange__checkout_typechanges(void)
38{
39 int i;
40 git_object *obj;
b81aa2f1 41 git_checkout_opts opts = GIT_CHECKOUT_OPTS_INIT;
0d64bef9 42
ad9a921b
RB
43 opts.checkout_strategy = GIT_CHECKOUT_FORCE;
44
0d64bef9
RB
45 for (i = 0; g_typechange_oids[i] != NULL; ++i) {
46 cl_git_pass(git_revparse_single(&obj, g_repo, g_typechange_oids[i]));
7e5c8a5b
RB
47
48 /* fprintf(stderr, "---- checking out '%s' ----\n", g_typechange_oids[i]); */
0d64bef9 49
30a46ab1 50 cl_git_pass(git_checkout_tree(g_repo, obj, &opts));
0d64bef9 51
ad9a921b
RB
52 cl_git_pass(
53 git_repository_set_head_detached(g_repo, git_object_id(obj)));
54
0d64bef9
RB
55 git_object_free(obj);
56
57 if (!g_typechange_empty[i]) {
58 cl_assert(git_path_isdir("typechanges"));
59 cl_assert(git_path_exists("typechanges/a"));
60 cl_assert(git_path_exists("typechanges/b"));
61 cl_assert(git_path_exists("typechanges/c"));
62 cl_assert(git_path_exists("typechanges/d"));
63 cl_assert(git_path_exists("typechanges/e"));
64 } else {
65 cl_assert(git_path_isdir("typechanges"));
66 cl_assert(!git_path_exists("typechanges/a"));
67 cl_assert(!git_path_exists("typechanges/b"));
68 cl_assert(!git_path_exists("typechanges/c"));
69 cl_assert(!git_path_exists("typechanges/d"));
70 cl_assert(!git_path_exists("typechanges/e"));
71 }
72 }
73}