summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@edwardthomson.com>2013-11-04 15:46:32 -0600
committerEdward Thomson <ethomson@microsoft.com>2013-11-04 22:32:50 -0500
commitf966acd13366d21e0b9beeecf021c0114596c716 (patch)
tree3564477bae4877f3accd9eb0963df9769369b3fe /src
parent0e1115d2872fcb8f13fd28a52f1f14d52792623e (diff)
downloadlibgit2-f966acd13366d21e0b9beeecf021c0114596c716.tar.gz
Take umask into account in filebuf_commit
Diffstat (limited to 'src')
-rw-r--r--src/filebuf.c6
-rw-r--r--src/odb_loose.c4
2 files changed, 7 insertions, 3 deletions
diff --git a/src/filebuf.c b/src/filebuf.c
index 714a32395..de2944bbc 100644
--- a/src/filebuf.c
+++ b/src/filebuf.c
@@ -320,9 +320,13 @@ int git_filebuf_commit_at(git_filebuf *file, const char *path, mode_t mode)
int git_filebuf_commit(git_filebuf *file, mode_t mode)
{
+ mode_t mask;
+
/* temporary files cannot be committed */
assert(file && file->path_original);
+ p_umask(mask = p_umask(0));
+
file->flush_mode = Z_FINISH;
flush_buffer(file);
@@ -338,7 +342,7 @@ int git_filebuf_commit(git_filebuf *file, mode_t mode)
file->fd = -1;
- if (p_chmod(file->path_lock, mode)) {
+ if (p_chmod(file->path_lock, (mode & ~mask))) {
giterr_set(GITERR_OS, "Failed to set attributes for file at '%s'", file->path_lock);
goto on_error;
}
diff --git a/src/odb_loose.c b/src/odb_loose.c
index 0dfd78aee..3e52edf05 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -902,8 +902,8 @@ int git_odb_backend_loose(
const char *objects_dir,
int compression_level,
int do_fsync,
- mode_t dir_mode,
- mode_t file_mode)
+ unsigned int dir_mode,
+ unsigned int file_mode)
{
loose_backend *backend;
size_t objects_dirlen;