checkout::crlf clear the crlf workdir for checkout After sandboxing the crlf directory, remove the working directory contents. This allows us to package data within the crlf directory (for simplicity, this allows us to script the to-odb and to-workdir crlf filter conversion data in a single location).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
diff --git a/tests/checkout/crlf.c b/tests/checkout/crlf.c
index 94fd8a6..0ad88b5 100644
--- a/tests/checkout/crlf.c
+++ b/tests/checkout/crlf.c
@@ -13,14 +13,38 @@ static git_repository *g_repo;
static const char *systype;
static git_buf expected_fixture = GIT_BUF_INIT;
+static int unlink_file(void *payload, git_buf *path)
+{
+ const char *fn = git_path_basename(path->ptr);
+
+ GIT_UNUSED(payload);
+
+ if (strcmp(fn, ".git"))
+ cl_must_pass(p_unlink(path->ptr));
+
+ git__free(fn);
+ return 0;
+}
+
void test_checkout_crlf__initialize(void)
{
+ git_buf reponame = GIT_BUF_INIT;
+
g_repo = cl_git_sandbox_init("crlf");
+ /*
+ * remove the contents of the working directory so that we can
+ * check out over it.
+ */
+ git_buf_puts(&reponame, "crlf");
+ cl_git_pass(git_path_direach(&reponame, 0, unlink_file, NULL));
+
if (GIT_EOL_NATIVE == GIT_EOL_CRLF)
systype = "windows";
else
systype = "posix";
+
+ git_buf_dispose(&reponame);
}
void test_checkout_crlf__cleanup(void)