Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/libgit2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@microsoft.com>2015-03-31 23:28:13 +0300
committerEdward Thomson <ethomson@edwardthomson.com>2015-05-04 15:18:27 +0300
commit05f690122e9927eece61afb17c1595a136d119b2 (patch)
tree40bb725acb3d51e816dd57583182431425182fad /tests/checkout
parent3520c97057a2e4236779d24ec6fece0d11514319 (diff)
checkout: remove blocking dir when FORCEd
Diffstat (limited to 'tests/checkout')
-rw-r--r--tests/checkout/icase.c98
1 files changed, 91 insertions, 7 deletions
diff --git a/tests/checkout/icase.c b/tests/checkout/icase.c
index 211738070..ae1a63b90 100644
--- a/tests/checkout/icase.c
+++ b/tests/checkout/icase.c
@@ -21,7 +21,7 @@ void test_checkout_icase__initialize(void)
cl_git_pass(git_object_lookup(&obj, repo, &id, GIT_OBJ_ANY));
git_checkout_init_options(&checkout_opts, GIT_CHECKOUT_OPTIONS_VERSION);
- checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_NONE;
}
void test_checkout_icase__cleanup(void)
@@ -79,8 +79,21 @@ static void assert_name_is(const char *expected)
free(actual);
}
-void test_checkout_icase__overwrites_files_for_files(void)
+void test_checkout_icase__refuses_to_overwrite_files_for_files(void)
+{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE|GIT_CHECKOUT_RECREATE_MISSING;
+
+ cl_git_write2file("testrepo/BRANCH_FILE.txt", "neue file\n", 10, \
+ O_WRONLY | O_CREAT | O_TRUNC, 0644);
+
+ cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
+ assert_name_is("testrepo/BRANCH_FILE.txt");
+}
+
+void test_checkout_icase__overwrites_files_for_files_when_forced(void)
{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
cl_git_write2file("testrepo/NEW.txt", "neue file\n", 10, \
O_WRONLY | O_CREAT | O_TRUNC, 0644);
@@ -88,8 +101,22 @@ void test_checkout_icase__overwrites_files_for_files(void)
assert_name_is("testrepo/new.txt");
}
-void test_checkout_icase__overwrites_links_for_files(void)
+void test_checkout_icase__refuses_to_overwrite_links_for_files(void)
{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE|GIT_CHECKOUT_RECREATE_MISSING;
+
+ cl_must_pass(p_symlink("../tmp", "testrepo/BRANCH_FILE.txt"));
+
+ cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
+
+ cl_assert(!git_path_exists("tmp"));
+ assert_name_is("testrepo/BRANCH_FILE.txt");
+}
+
+void test_checkout_icase__overwrites_links_for_files_when_forced(void)
+{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
cl_must_pass(p_symlink("../tmp", "testrepo/NEW.txt"));
cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
@@ -98,9 +125,39 @@ void test_checkout_icase__overwrites_links_for_files(void)
assert_name_is("testrepo/new.txt");
}
-void test_checkout_icase__overwites_folders_for_files(void)
+void test_checkout_icase__overwrites_empty_folders_for_files(void)
+{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE|GIT_CHECKOUT_RECREATE_MISSING;
+
+ cl_must_pass(p_mkdir("testrepo/NEW.txt", 0777));
+
+ cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
+
+ assert_name_is("testrepo/new.txt");
+ cl_assert(!git_path_isdir("testrepo/new.txt"));
+}
+
+void test_checkout_icase__refuses_to_overwrite_populated_folders_for_files(void)
+{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE|GIT_CHECKOUT_RECREATE_MISSING;
+
+ cl_must_pass(p_mkdir("testrepo/BRANCH_FILE.txt", 0777));
+ cl_git_write2file("testrepo/BRANCH_FILE.txt/foobar", "neue file\n", 10, \
+ O_WRONLY | O_CREAT | O_TRUNC, 0644);
+
+ cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
+
+ assert_name_is("testrepo/BRANCH_FILE.txt");
+ cl_assert(git_path_isdir("testrepo/BRANCH_FILE.txt"));
+}
+
+void test_checkout_icase__overwrites_folders_for_files_when_forced(void)
{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
cl_must_pass(p_mkdir("testrepo/NEW.txt", 0777));
+ cl_git_write2file("testrepo/NEW.txt/foobar", "neue file\n", 10, \
+ O_WRONLY | O_CREAT | O_TRUNC, 0644);
cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
@@ -108,8 +165,22 @@ void test_checkout_icase__overwites_folders_for_files(void)
cl_assert(!git_path_isdir("testrepo/new.txt"));
}
-void test_checkout_icase__overwrites_files_for_folders(void)
+void test_checkout_icase__refuses_to_overwrite_files_for_folders(void)
{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE|GIT_CHECKOUT_RECREATE_MISSING;
+
+ cl_git_write2file("testrepo/A", "neue file\n", 10, \
+ O_WRONLY | O_CREAT | O_TRUNC, 0644);
+
+ cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
+ assert_name_is("testrepo/A");
+ cl_assert(!git_path_isdir("testrepo/A"));
+}
+
+void test_checkout_icase__overwrites_files_for_folders_when_forced(void)
+{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
cl_git_write2file("testrepo/A", "neue file\n", 10, \
O_WRONLY | O_CREAT | O_TRUNC, 0644);
@@ -118,8 +189,22 @@ void test_checkout_icase__overwrites_files_for_folders(void)
cl_assert(git_path_isdir("testrepo/a"));
}
-void test_checkout_icase__overwrites_links_for_folders(void)
+void test_checkout_icase__refuses_to_overwrite_links_for_folders(void)
+{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_SAFE|GIT_CHECKOUT_RECREATE_MISSING;
+
+ cl_must_pass(p_symlink("..", "testrepo/A"));
+
+ cl_git_fail(git_checkout_tree(repo, obj, &checkout_opts));
+
+ cl_assert(!git_path_exists("b.txt"));
+ assert_name_is("testrepo/A");
+}
+
+void test_checkout_icase__overwrites_links_for_folders_when_forced(void)
{
+ checkout_opts.checkout_strategy = GIT_CHECKOUT_FORCE;
+
cl_must_pass(p_symlink("..", "testrepo/A"));
cl_git_pass(git_checkout_tree(repo, obj, &checkout_opts));
@@ -127,4 +212,3 @@ void test_checkout_icase__overwrites_links_for_folders(void)
cl_assert(!git_path_exists("b.txt"));
assert_name_is("testrepo/a");
}
-