summaryrefslogtreecommitdiff
path: root/src/refdb_fs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/refdb_fs.c')
-rw-r--r--src/refdb_fs.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index d7a458a87..ade50f7c3 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -62,6 +62,7 @@ typedef struct refdb_fs_backend {
int peeling_mode;
git_iterator_flag_t iterator_flags;
uint32_t direach_flags;
+ int fsync;
} refdb_fs_backend;
static int refdb_reflog_fs__delete(git_refdb_backend *_backend, const char *name);
@@ -756,7 +757,7 @@ static int loose_lock(git_filebuf *file, refdb_fs_backend *backend, const char *
return -1;
filebuf_flags = GIT_FILEBUF_FORCE;
- if (git_object__synchronous_writing)
+ if (backend->fsync)
filebuf_flags |= GIT_FILEBUF_FSYNC;
error = git_filebuf_open(file, ref_path.ptr, filebuf_flags, GIT_REFS_FILE_MODE);
@@ -1001,7 +1002,7 @@ static int packed_write(refdb_fs_backend *backend)
if ((error = git_sortedcache_wlock(refcache)) < 0)
return error;
- if (git_object__synchronous_writing)
+ if (backend->fsync)
open_flags = GIT_FILEBUF_FSYNC;
/* Open the file! */
@@ -1861,7 +1862,7 @@ static int reflog_append(refdb_fs_backend *backend, const git_reference *ref, co
open_flags = O_WRONLY | O_CREAT | O_APPEND;
- if (git_object__synchronous_writing)
+ if (backend->fsync)
open_flags |= O_FSYNC;
error = git_futils_writebuffer(&buf, git_buf_cstr(&path), open_flags, GIT_REFLOG_FILE_MODE);
@@ -2014,6 +2015,9 @@ int git_refdb_backend_fs(
backend->iterator_flags |= GIT_ITERATOR_PRECOMPOSE_UNICODE;
backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
}
+ if ((!git_repository__cvar(&t, backend->repo, GIT_CVAR_FSYNCOBJECTFILES) && t) ||
+ git_object__synchronous_writing)
+ backend->fsync = 1;
backend->parent.exists = &refdb_fs_backend__exists;
backend->parent.lookup = &refdb_fs_backend__lookup;