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:
authorJameson Miller <jamill@microsoft.com>2013-03-01 20:07:53 +0400
committerJameson Miller <jamill@microsoft.com>2013-03-01 23:56:09 +0400
commit926acbcf8ed80a69ab82f3d14e90dabeca9af07d (patch)
tree550f4e6314038033bbbced49b5934e1706405278 /tests-clar/clone
parentcc427158d4fafa26e3d2d9f69da51a1a8d8a92d4 (diff)
Clone should not delete directories it did not create
Diffstat (limited to 'tests-clar/clone')
-rw-r--r--tests-clar/clone/nonetwork.c37
1 files changed, 37 insertions, 0 deletions
diff --git a/tests-clar/clone/nonetwork.c b/tests-clar/clone/nonetwork.c
index 3d327cb1e..2c4cba4eb 100644
--- a/tests-clar/clone/nonetwork.c
+++ b/tests-clar/clone/nonetwork.c
@@ -52,6 +52,43 @@ void test_clone_nonetwork__bad_url(void)
cl_assert(!git_path_exists("./foo"));
}
+static int dont_call_me(void *state, git_buf *path)
+{
+ GIT_UNUSED(state);
+ GIT_UNUSED(path);
+ return GIT_ERROR;
+}
+
+void test_clone_nonetwork__do_not_clean_existing_directory(void)
+{
+ git_buf path_buf = GIT_BUF_INIT;
+
+ git_buf_put(&path_buf, "./foo", 5);
+
+ /* Clone should not remove the directory if it already exists, but
+ * Should clean up entries it creates. */
+ p_mkdir("./foo", GIT_DIR_MODE);
+ cl_git_fail(git_clone(&g_repo, "not_a_repo", "./foo", &g_options));
+ cl_assert(git_path_exists("./foo"));
+
+ /* Make sure the directory is empty. */
+ cl_git_pass(git_path_direach(&path_buf,
+ dont_call_me,
+ NULL));
+
+ /* Try again with a bare repository. */
+ g_options.bare = true;
+ cl_git_fail(git_clone(&g_repo, "not_a_repo", "./foo", &g_options));
+ cl_assert(git_path_exists("./foo"));
+
+ /* Make sure the directory is empty. */
+ cl_git_pass(git_path_direach(&path_buf,
+ dont_call_me,
+ NULL));
+
+ git_buf_free(&path_buf);
+}
+
void test_clone_nonetwork__local(void)
{
cl_git_pass(git_clone(&g_repo, cl_git_fixture_url("testrepo.git"), "./foo", &g_options));