Skip to content

Commit e476d52

Browse files
authored
Merge pull request libgit2#4259 from pks-t/pks/fsync-option-rename
settings: rename `GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION`
2 parents 458cea5 + 6c23704 commit e476d52

File tree

12 files changed

+18
-16
lines changed

12 files changed

+18
-16
lines changed

include/git2/common.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ typedef enum {
179179
GIT_OPT_SET_SSL_CIPHERS,
180180
GIT_OPT_GET_USER_AGENT,
181181
GIT_OPT_ENABLE_OFS_DELTA,
182-
GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION,
182+
GIT_OPT_ENABLE_FSYNC_GITDIR,
183183
GIT_OPT_GET_WINDOWS_SHAREMODE,
184184
GIT_OPT_SET_WINDOWS_SHAREMODE,
185185
GIT_OPT_ENABLE_STRICT_HASH_VERIFICATION,
@@ -331,9 +331,9 @@ typedef enum {
331331
* > Packfiles containing offset deltas can still be read.
332332
* > This defaults to enabled.
333333
*
334-
* * opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, int enabled)
334+
* * opts(GIT_OPT_ENABLE_FSYNC_GITDIR, int enabled)
335335
*
336-
* > Enable synchronized writes of new objects using `fsync`
336+
* > Enable synchronized writes of files in the gitdir using `fsync`
337337
* > (or the platform equivalent) to ensure that new object data
338338
* > is written to permanent storage, not simply cached. This
339339
* > defaults to disabled.

src/indexer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ int git_indexer_new(
125125
git_hash_ctx_init(&idx->hash_ctx);
126126
git_hash_ctx_init(&idx->trailer);
127127

128-
if (git_object__synchronous_writing)
128+
if (git_repository__fsync_gitdir)
129129
idx->do_fsync = 1;
130130

131131
error = git_buf_joinpath(&path, prefix, suff);

src/object.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
#include "tag.h"
1717

1818
bool git_object__strict_input_validation = true;
19-
bool git_object__synchronous_writing = false;
2019

2120
typedef struct {
2221
const char *str; /* type name string */

src/object.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "repository.h"
1111

1212
extern bool git_object__strict_input_validation;
13-
extern bool git_object__synchronous_writing;
1413

1514
/** Base git object for inheritance */
1615
struct git_object {

src/odb_loose.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -850,7 +850,7 @@ static int filebuf_flags(loose_backend *backend)
850850
int flags = GIT_FILEBUF_TEMPORARY |
851851
(backend->object_zlib_level << GIT_FILEBUF_DEFLATE_SHIFT);
852852

853-
if (backend->fsync_object_files || git_object__synchronous_writing)
853+
if (backend->fsync_object_files || git_repository__fsync_gitdir)
854854
flags |= GIT_FILEBUF_FSYNC;
855855

856856
return flags;

src/refdb_fs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2032,7 +2032,7 @@ int git_refdb_backend_fs(
20322032
backend->direach_flags |= GIT_PATH_DIR_PRECOMPOSE_UNICODE;
20332033
}
20342034
if ((!git_repository__cvar(&t, backend->repo, GIT_CVAR_FSYNCOBJECTFILES) && t) ||
2035-
git_object__synchronous_writing)
2035+
git_repository__fsync_gitdir)
20362036
backend->fsync = 1;
20372037

20382038
backend->parent.exists = &refdb_fs_backend__exists;

src/repository.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
# include "win32/w32_util.h"
3737
#endif
3838

39+
bool git_repository__fsync_gitdir = false;
40+
3941
static const struct {
4042
git_repository_item_t parent;
4143
const char *name;

src/repository.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
/* Default DOS-compatible 8.3 "short name" for a git repository, "GIT~1" */
3232
#define GIT_DIR_SHORTNAME "GIT~1"
3333

34+
extern bool git_repository__fsync_gitdir;
35+
3436
/** Cvar cache identifiers */
3537
typedef enum {
3638
GIT_CVAR_AUTO_CRLF = 0, /* core.autocrlf */

src/settings.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,8 @@ int git_libgit2_opts(int key, ...)
228228
git_smart__ofs_delta_enabled = (va_arg(ap, int) != 0);
229229
break;
230230

231-
case GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION:
232-
git_object__synchronous_writing = (va_arg(ap, int) != 0);
231+
case GIT_OPT_ENABLE_FSYNC_GITDIR:
232+
git_repository__fsync_gitdir = (va_arg(ap, int) != 0);
233233
break;
234234

235235
case GIT_OPT_GET_WINDOWS_SHAREMODE:

tests/odb/loose.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ void test_odb_loose__initialize(void)
6363

6464
void test_odb_loose__cleanup(void)
6565
{
66-
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 0));
66+
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 0));
6767
cl_fixture_cleanup("test-objects");
6868
}
6969

@@ -181,7 +181,7 @@ void test_odb_loose__fsync_obeys_odb_option(void)
181181

182182
void test_odb_loose__fsync_obeys_global_setting(void)
183183
{
184-
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_SYNCHRONOUS_OBJECT_CREATION, 1));
184+
cl_git_pass(git_libgit2_opts(GIT_OPT_ENABLE_FSYNC_GITDIR, 1));
185185
write_object_to_loose_odb(0);
186186
cl_assert(p_fsync__cnt > 0);
187187
}

0 commit comments

Comments
 (0)