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:
authorEdward Thomson <ethomson@edwardthomson.com>2013-11-05 01:46:32 +0400
committerEdward Thomson <ethomson@microsoft.com>2013-11-05 07:32:50 +0400
commitf966acd13366d21e0b9beeecf021c0114596c716 (patch)
tree3564477bae4877f3accd9eb0963df9769369b3fe /tests-clar
parent0e1115d2872fcb8f13fd28a52f1f14d52792623e (diff)
Take umask into account in filebuf_commit
Diffstat (limited to 'tests-clar')
-rw-r--r--tests-clar/core/filebuf.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests-clar/core/filebuf.c b/tests-clar/core/filebuf.c
index bf2167057..646d42c6e 100644
--- a/tests-clar/core/filebuf.c
+++ b/tests-clar/core/filebuf.c
@@ -90,3 +90,37 @@ void test_core_filebuf__5(void)
cl_must_pass(p_unlink(test));
}
+
+
+/* make sure git_filebuf_commit takes umask into account */
+void test_core_filebuf__umask(void)
+{
+ git_filebuf file = GIT_FILEBUF_INIT;
+ char test[] = "test";
+ struct stat statbuf;
+ mode_t mask, os_mask;
+
+#ifdef GIT_WIN32
+ os_mask = 0600;
+#else
+ os_mask = 0777;
+#endif
+
+ p_umask(mask = p_umask(0));
+
+ cl_assert(file.buffer == NULL);
+
+ cl_git_pass(git_filebuf_open(&file, test, 0));
+ cl_assert(file.buffer != NULL);
+ cl_git_pass(git_filebuf_printf(&file, "%s\n", "libgit2 rocks"));
+ cl_assert(file.buffer != NULL);
+
+ cl_git_pass(git_filebuf_commit(&file, 0666));
+ cl_assert(file.buffer == NULL);
+
+ cl_must_pass(p_stat("test", &statbuf));
+ cl_assert_equal_i(statbuf.st_mode & os_mask, (0666 & ~mask) & os_mask);
+
+ cl_must_pass(p_unlink(test));
+}
+