Commit c3169e6f62960e5c667c77bbaadb396ad6300efd

Edward Thomson 2018-12-01T19:59:41

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).

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)