summaryrefslogtreecommitdiff
path: root/tests-clar/reset/hard.c
diff options
context:
space:
mode:
authornulltoken <emeric.fermas@gmail.com>2012-08-19 21:24:51 +0200
committernulltoken <emeric.fermas@gmail.com>2012-09-17 10:48:28 +0200
commitee8bb8ba649118c4abb09cb02bd3c02e60b98e06 (patch)
treebcbcdb7e25aac03a883de3f15de977192602e4da /tests-clar/reset/hard.c
parente93af304112735f02bfeb0833b58ed8230de2371 (diff)
downloadlibgit2-ee8bb8ba649118c4abb09cb02bd3c02e60b98e06.tar.gz
reset: add support for GIT_RESET_HARD mode
Diffstat (limited to 'tests-clar/reset/hard.c')
-rw-r--r--tests-clar/reset/hard.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests-clar/reset/hard.c b/tests-clar/reset/hard.c
new file mode 100644
index 000000000..ad3badb8a
--- /dev/null
+++ b/tests-clar/reset/hard.c
@@ -0,0 +1,46 @@
+#include "clar_libgit2.h"
+#include "posix.h"
+#include "reset_helpers.h"
+#include "path.h"
+#include "fileops.h"
+
+static git_repository *repo;
+static git_object *target;
+
+void test_reset_hard__initialize(void)
+{
+ repo = cl_git_sandbox_init("status");
+ target = NULL;
+}
+
+void test_reset_hard__cleanup(void)
+{
+ git_object_free(target);
+ cl_git_sandbox_cleanup();
+}
+
+void test_reset_hard__resetting_culls_empty_directories(void)
+{
+ git_buf subdir_path = GIT_BUF_INIT;
+ git_buf subfile_path = GIT_BUF_INIT;
+ git_buf newdir_path = GIT_BUF_INIT;
+
+ cl_git_pass(git_buf_joinpath(&newdir_path, git_repository_workdir(repo), "newdir/"));
+
+ cl_git_pass(git_buf_joinpath(&subfile_path, git_buf_cstr(&newdir_path), "with/nested/file.txt"));
+ cl_git_pass(git_futils_mkpath2file(git_buf_cstr(&subfile_path), 0755));
+ cl_git_mkfile(git_buf_cstr(&subfile_path), "all anew...\n");
+
+ cl_git_pass(git_buf_joinpath(&subdir_path, git_repository_workdir(repo), "subdir/"));
+ cl_assert(git_path_isdir(git_buf_cstr(&subdir_path)) == true);
+
+ retrieve_target_from_oid(&target, repo, "0017bd4ab1ec30440b17bae1680cff124ab5f1f6");
+ cl_git_pass(git_reset(repo, target, GIT_RESET_HARD));
+
+ cl_assert(git_path_isdir(git_buf_cstr(&subdir_path)) == false);
+ cl_assert(git_path_isdir(git_buf_cstr(&newdir_path)) == false);
+
+ git_buf_free(&subdir_path);
+ git_buf_free(&subfile_path);
+ git_buf_free(&newdir_path);
+}