Commit ea3f2c296aa39b9609db3d75c96837518beb12a3

Edward Thomson 2015-09-08T14:35:53

filebuf: ensure we can lock a hidden file

diff --git a/tests/core/filebuf.c b/tests/core/filebuf.c
index 39d98ff..915e3cc 100644
--- a/tests/core/filebuf.c
+++ b/tests/core/filebuf.c
@@ -204,3 +204,29 @@ void test_core_filebuf__symlink_depth(void)
 
 	cl_git_pass(git_futils_rmdir_r(dir, NULL, GIT_RMDIR_REMOVE_FILES));
 }
+
+void test_core_filebuf__hidden_file(void)
+{
+#ifndef GIT_WIN32
+	cl_skip();
+#else
+	git_filebuf file = GIT_FILEBUF_INIT;
+	char *dir = "hidden", *test = "hidden/test";
+	bool hidden;
+
+	cl_git_pass(p_mkdir(dir, 0666));
+	cl_git_mkfile(test, "dummy content");
+
+	cl_git_pass(git_win32__set_hidden(test, true));
+	cl_git_pass(git_win32__hidden(&hidden, test));
+	cl_assert(hidden);
+
+	cl_git_pass(git_filebuf_open(&file, test, 0, 0666));
+
+	cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
+
+	cl_git_pass(git_filebuf_commit(&file));
+
+	git_filebuf_cleanup(&file);
+#endif
+}