Merge pull request #4259 from pks-t/pks/fsync-option-rename settings: rename `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195
diff --git a/include/git2/common.h b/include/git2/common.h
index d83e8c3..f65cfdd 100644
--- a/include/git2/common.h
+++ b/include/git2/common.h
@@ -179,7 +179,7 @@ typedef enum {
GIT_OPT_SET_SSL_CIPHERS,
GIT_OPT_GET_USER_AGENT,
GIT_OPT_ENABLE_OFS_DELTA,
- GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION,
+ GIT_OPT_ENABLE_FSYNC_GITDIR,
GIT_OPT_GET_WINDOWS_SHAREMODE,
GIT_OPT_SET_WINDOWS_SHAREMODE,
GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION,
@@ -331,9 +331,9 @@ typedef enum {
* > Packfiles containing offset deltas can still be read.
* > This defaults to enabled.
*
- * * opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, int enabled)
+ * * opts(GIT_OPT_ENABLE_FSYNC_GITDIR, int enabled)
*
- * > Enable synchronized writes of new objects using `fsync`
+ * > Enable synchronized writes of files in the gitdir using `fsync`
* > (or the platform equivalent) to ensure that new object data
* > is written to permanent storage, not simply cached. This
* > defaults to disabled.
diff --git a/src/indexer.c b/src/indexer.c
index ce67240..68cd205 100644
--- a/src/indexer.c
+++ b/src/indexer.c
@@ -125,7 +125,7 @@ int git_indexer_new(
git_hash_ctx_init(&idx->hash_ctx);
git_hash_ctx_init(&idx->trailer);
- if (git_object__synchronous_writing)
+ if (git_repository__fsync_gitdir)
idx->do_fsync = 1;
error = git_buf_joinpath(&path, prefix, suff);
diff --git a/src/object.c b/src/object.c
index bd87c93..2da36a2 100644
--- a/src/object.c
+++ b/src/object.c
@@ -16,7 +16,6 @@
#include "tag.h"
bool git_object__strict_input_validation = true;
-bool git_object__synchronous_writing = false;
typedef struct {
const char *str; /* type name string */
diff --git a/src/object.h b/src/object.h
index 13117e4..dd227d1 100644
--- a/src/object.h
+++ b/src/object.h
@@ -10,7 +10,6 @@
#include "repository.h"
extern bool git_object__strict_input_validation;
-extern bool git_object__synchronous_writing;
/** Base git object for inheritance */
struct git_object {
diff --git a/src/odb_loose.c b/src/odb_loose.c
index a97ac25..99fdcb4 100644
--- a/src/odb_loose.c
+++ b/src/odb_loose.c
@@ -850,7 +850,7 @@ static int filebuf_flags(loose_backend *backend)
int flags = GIT_FILEBUF_TEMPORARY |
(backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT);
- if (backend->fsync_object_files || git_object__synchronous_writing)
+ if (backend->fsync_object_files || git_repository__fsync_gitdir)
flags |= GIT_FILEBUF_FSYNC;
return flags;
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 988a14b..eb135dc 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -2032,7 +2032,7 @@ int git_refdb_backend_fs(
backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
}
if ((!git_repository__cvar(&t, backend->repo, GIT_CVAR_FSYNCOBJECTFILES) && t) ||
- git_object__synchronous_writing)
+ git_repository__fsync_gitdir)
backend->fsync = 1;
backend->parent.exists = &refdb_fs_backend__exists;
diff --git a/src/repository.c b/src/repository.c
index d0a38cc..c7b40fd 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -36,6 +36,8 @@
# include "win32/w32_util.h"
#endif
+bool git_repository__fsync_gitdir = false;
+
static const struct {
git_repository_item_t parent;
const char *name;
diff --git a/src/repository.h b/src/repository.h
index f922d00..52f9ec2 100644
--- a/src/repository.h
+++ b/src/repository.h
@@ -31,6 +31,8 @@
/* Default DOS-compatible 8.3 "short name" for a git repository, "GIT~1" */
#define GIT_DIR_SHORTNAME "GIT~1"
+extern bool git_repository__fsync_gitdir;
+
/** Cvar cache identifiers */
typedef enum {
GIT_CVAR_AUTO_CRLF = 0, /* core.autocrlf */
diff --git a/src/settings.c b/src/settings.c
index 25c5aae..52b861b 100644
--- a/src/settings.c
+++ b/src/settings.c
@@ -228,8 +228,8 @@ int git_libgit2_opts(int key, ...)
git_smart__ofs_delta_enabled = (va_arg(ap, int) != 0);
break;
- case GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION:
- git_object__synchronous_writing = (va_arg(ap, int) != 0);
+ case GIT_OPT_ENABLE_FSYNC_GITDIR:
+ git_repository__fsync_gitdir = (va_arg(ap, int) != 0);
break;
case GIT_OPT_GET_WINDOWS_SHAREMODE:
diff --git a/tests/odb/loose.c b/tests/odb/loose.c
index dd686aa..2e24d67 100644
--- a/tests/odb/loose.c
+++ b/tests/odb/loose.c
@@ -63,7 +63,7 @@ void test_odb_loose__initialize(void)
void test_odb_loose__cleanup(void)
{
- cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 0));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 0));
cl_fixture_cleanup("test-objects");
}
@@ -181,7 +181,7 @@ void test_odb_loose__fsync_obeys_odb_option(void)
void test_odb_loose__fsync_obeys_global_setting(void)
{
- cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 1));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 1));
write_object_to_loose_odb(0);
cl_assert(p_fsync__cnt > 0);
}
diff --git a/tests/pack/packbuilder.c b/tests/pack/packbuilder.c
index 1d7bece..9bea203 100644
--- a/tests/pack/packbuilder.c
+++ b/tests/pack/packbuilder.c
@@ -31,7 +31,7 @@ void test_pack_packbuilder__cleanup(void)
git_oid *o;
unsigned int i;
- cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 0));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 0));
if (_commits_is_initialized) {
_commits_is_initialized = 0;
@@ -209,7 +209,7 @@ static int expected_fsyncs = 4;
void test_pack_packbuilder__fsync_global_setting(void)
{
- cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 1));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 1));
p_fsync__cnt = 0;
seed_packbuilder();
git_packbuilder_write(_packbuilder, ".", 0666, NULL, NULL);
diff --git a/tests/refs/create.c b/tests/refs/create.c
index 4ecc605..469cddd 100644
--- a/tests/refs/create.c
+++ b/tests/refs/create.c
@@ -22,7 +22,7 @@ void test_refs_create__cleanup(void)
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_OBJECT_CREATION, 1));
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_STRICT_SYMBOLIC_REF_CREATION, 1));
- cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 0));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 0));
}
void test_refs_create__symbolic(void)
@@ -347,7 +347,7 @@ void test_refs_create__fsyncs_when_global_opt_set(void)
{
size_t create_count, compress_count;
- cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 1));
+ cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 1));
count_fsyncs(&create_count, &compress_count);
cl_assert_equal_i(expected_fsyncs_create, create_count);