Add EnableFsyncGitDir to enable synchronized writes to the gitdir (#874) (#877)

This adds support for the GIT_OPT_ENABLE_FSYNC_GITDIR option in libgit2.

Co-authored-by: James Fargher <jfargher@gitlab.com>
(cherry picked from commit 1fcc9d8743)

Co-authored-by: James Fargher <proglottis@gmail.com>
This commit is contained in:
github-actions[bot] 2022-01-17 19:00:12 -08:00 committed by GitHub
parent a964575453
commit a3f32b93cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)