Add EnableFsyncGitDir to enable synchronized writes to the gitdir #874

Merged
proglottis merged 1 commits from enable_fsync_gitdir into main 2022-01-17 20:51:39 -06:00
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)