mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-02 21:34:15 +00:00
Add ENABLE_SYNCHRONIZED_OBJECT_CREATION
option
Allow users to enable `SYNCHRONIZED_OBJECT_CREATION` with a setting.
This commit is contained in:
parent
fc27fe213c
commit
6d3ad7e09e
@ -179,6 +179,7 @@ typedef enum {
|
||||
GIT_OPT_SET_SSL_CIPHERS,
|
||||
GIT_OPT_GET_USER_AGENT,
|
||||
GIT_OPT_ENABLE_OFS_DELTA,
|
||||
GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION,
|
||||
} git_libgit2_opt_t;
|
||||
|
||||
/**
|
||||
@ -316,6 +317,13 @@ typedef enum {
|
||||
* > Packfiles containing offset deltas can still be read.
|
||||
* > This defaults to enabled.
|
||||
*
|
||||
* * opts(GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION, int enabled)
|
||||
*
|
||||
* > Enable synchronized writes of new objects using `fsync`
|
||||
* > (or the platform equivalent) to ensure that new object data
|
||||
* > is written to permanent storage, not simply cached. This
|
||||
* > defaults to disabled.
|
||||
*
|
||||
* @param option Option key
|
||||
* @param ... value to set the option
|
||||
* @return 0 on success, <0 on failure
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "tag.h"
|
||||
|
||||
bool git_object__strict_input_validation = true;
|
||||
bool git_object__synchronized_writing = false;
|
||||
|
||||
typedef struct {
|
||||
const char *str; /* type name string */
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "repository.h"
|
||||
|
||||
extern bool git_object__strict_input_validation;
|
||||
extern bool git_object__synchronized_writing;
|
||||
|
||||
/** Base git object for inheritance */
|
||||
struct git_object {
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "odb.h"
|
||||
#include "delta.h"
|
||||
#include "filebuf.h"
|
||||
#include "object.h"
|
||||
|
||||
#include "git2/odb_backend.h"
|
||||
#include "git2/types.h"
|
||||
@ -843,7 +844,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)
|
||||
if (backend->fsync_object_files || git_object__synchronized_writing)
|
||||
flags |= GIT_FILEBUF_FSYNC;
|
||||
|
||||
return flags;
|
||||
|
@ -227,6 +227,10 @@ int git_libgit2_opts(int key, ...)
|
||||
git_smart__ofs_delta_enabled = (va_arg(ap, int) != 0);
|
||||
break;
|
||||
|
||||
case GIT_OPT_ENABLE_SYNCHRONIZED_OBJECT_CREATION:
|
||||
git_object__synchronized_writing = (va_arg(ap, int) != 0);
|
||||
break;
|
||||
|
||||
default:
|
||||
giterr_set(GITERR_INVALID, "invalid option key");
|
||||
error = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user