Skip to content

Commit

Permalink
Add EnableFsyncGitDir to enable synchronized writes to the gitdir (#874
Browse files Browse the repository at this point in the history
…) (#876)

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 1fcc9d8)

Co-authored-by: James Fargher <proglottis@gmail.com>
  • Loading branch information
github-actions[bot] and proglottis authored Jan 18, 2022
1 parent 650a1de commit b1120d3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
8 changes: 8 additions & 0 deletions settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
8 changes: 8 additions & 0 deletions settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit b1120d3

Please sign in to comment.