summaryrefslogtreecommitdiff
path: root/src/repository.c
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2017-02-28 12:29:29 +0000
committerEdward Thomson <ethomson@github.com>2017-03-02 09:11:33 +0000
commit1c04a96b25da048221f31ecee0227d960dc00489 (patch)
tree14774879d60dec45b5610cb7ed1bae927ef2016f /src/repository.c
parent3ac05d11493d0573dbf725a19403dbf5e8d93b50 (diff)
downloadlibgit2-ethomson/fsync.tar.gz
Honor `core.fsyncObjectFiles`ethomson/fsync
Diffstat (limited to 'src/repository.c')
-rw-r--r--src/repository.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/src/repository.c b/src/repository.c
index 0db481638..425ef796f 100644
--- a/src/repository.c
+++ b/src/repository.c
@@ -1055,18 +1055,22 @@ int git_repository_odb__weakptr(git_odb **out, git_repository *repo)
git_odb *odb;
if ((error = git_repository_item_path(&odb_path, repo,
- GIT_REPOSITORY_ITEM_OBJECTS)) < 0)
+ GIT_REPOSITORY_ITEM_OBJECTS)) < 0 ||
+ (error = git_odb_new(&odb)) < 0)
return error;
- error = git_odb_open(&odb, odb_path.ptr);
- if (!error) {
- GIT_REFCOUNT_OWN(odb, repo);
+ GIT_REFCOUNT_OWN(odb, repo);
- odb = git__compare_and_swap(&repo->_odb, NULL, odb);
- if (odb != NULL) {
- GIT_REFCOUNT_OWN(odb, NULL);
- git_odb_free(odb);
- }
+ if ((error = git_odb__set_caps(odb, GIT_ODB_CAP_FROM_OWNER)) < 0 ||
+ (error = git_odb__add_default_backends(odb, odb_path.ptr, 0, 0)) < 0) {
+ git_odb_free(odb);
+ return error;
+ }
+
+ odb = git__compare_and_swap(&repo->_odb, NULL, odb);
+ if (odb != NULL) {
+ GIT_REFCOUNT_OWN(odb, NULL);
+ git_odb_free(odb);
}
git_buf_free(&odb_path);