summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Fargher <[email protected]>2022-01-18 15:51:39 +1300
committerGitHub <[email protected]>2022-01-17 18:51:39 -0800
commit1fcc9d87430e41cc333ce5b2431df7058e03bbb7 (patch)
treec09d4afbe4a6b533e494140bd7162b7b9b32424c
parent5e35338d58b589939b599c98ec9e6b44f94de20a (diff)
Add EnableFsyncGitDir to enable synchronized writes to the gitdir (#874)
This adds support for the GIT_OPT_ENABLE_FSYNC_GITDIR option in libgit2. Co-authored-by: James Fargher <[email protected]>
-rw-r--r--settings.go8
-rw-r--r--settings_test.go8
2 files changed, 16 insertions, 0 deletions
diff --git a/settings.go b/settings.go
index 9325618..7f9b5b1 100644
--- a/settings.go
+++ b/settings.go
@@ -101,6 +101,14 @@ func EnableStrictHashVerification(enabled bool) error {
}
}
+func EnableFsyncGitDir(enabled bool) error {
+ if enabled {
+ return setSizet(C.GIT_OPT_ENABLE_FSYNC_GITDIR, 1)
+ } else {
+ return setSizet(C.GIT_OPT_ENABLE_FSYNC_GITDIR, 0)
+ }
+}
+
func CachedMemory() (current int, allowed int, err error) {
return getSizetSizet(C.GIT_OPT_GET_CACHED_MEMORY)
}
diff --git a/settings_test.go b/settings_test.go
index 47eb711..e3761d4 100644
--- a/settings_test.go
+++ b/settings_test.go
@@ -65,6 +65,14 @@ func TestEnableStrictHashVerification(t *testing.T) {
checkFatal(t, err)
}
+func TestEnableFsyncGitDir(t *testing.T) {
+ err := EnableFsyncGitDir(false)
+ checkFatal(t, err)
+
+ err = EnableFsyncGitDir(true)
+ checkFatal(t, err)
+}
+
func TestCachedMemory(t *testing.T) {
current, allowed, err := CachedMemory()
checkFatal(t, err)