Add EnableFsyncGitDir to enable synchronized writes to the gitdir

This adds support for the GIT_OPT_ENABLE_FSYNC_GITDIR option in libgit2.
This commit is contained in:
James Fargher 2022-01-18 09:58:12 +13:00
parent 5e35338d58
commit 8b9674bb66
2 changed files with 16 additions and 0 deletions

View File

@ -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)
}

View File

@ -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)