summaryrefslogtreecommitdiff
path: root/src/refdb_fs.c
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2013-04-22 16:41:56 +0200
committerVicent Marti <tanoku@gmail.com>2013-04-22 16:41:56 +0200
commit0edad3cc0451a42b566d70f64611acc214a03022 (patch)
tree9a7c4c7e7ab0be366df168b7f1750f58b8bd86ae /src/refdb_fs.c
parent4ef2c79cb6dc81e17b68ccf7c270bcc7e4f85bfb (diff)
parentf063a75882769cb6fc652de425ac16ba4b88b616 (diff)
downloadlibgit2-vmg/dupe-odb-backends.tar.gz
Merge branch 'development' into vmg/dupe-odb-backendsvmg/dupe-odb-backends
Conflicts: src/odb.c
Diffstat (limited to 'src/refdb_fs.c')
-rw-r--r--src/refdb_fs.c42
1 files changed, 20 insertions, 22 deletions
diff --git a/src/refdb_fs.c b/src/refdb_fs.c
index 784749fd3..443871005 100644
--- a/src/refdb_fs.c
+++ b/src/refdb_fs.c
@@ -18,7 +18,8 @@
#include <git2/tag.h>
#include <git2/object.h>
#include <git2/refdb.h>
-#include <git2/refdb_backend.h>
+#include <git2/sys/refdb_backend.h>
+#include <git2/sys/refs.h>
GIT__USE_STRMAP;
@@ -42,7 +43,6 @@ typedef struct refdb_fs_backend {
git_repository *repo;
const char *path;
- git_refdb *refdb;
git_refcache refcache;
} refdb_fs_backend;
@@ -62,7 +62,7 @@ static int reference_read(
/* Determine the full path of the file */
if (git_buf_joinpath(&path, repo_path, ref_name) < 0)
return -1;
-
+
result = git_futils_readbuffer_updated(file_content, path.ptr, mtime, NULL, updated);
git_buf_free(&path);
@@ -175,7 +175,7 @@ static int packed_load(refdb_fs_backend *backend)
ref_cache->packfile = git_strmap_alloc();
GITERR_CHECK_ALLOC(ref_cache->packfile);
}
-
+
result = reference_read(&packfile, &ref_cache->packfile_time,
backend->path, GIT_PACKEDREFS_FILE, &updated);
@@ -193,7 +193,7 @@ static int packed_load(refdb_fs_backend *backend)
if (result < 0)
return -1;
-
+
if (!updated)
return 0;
@@ -430,12 +430,12 @@ static int loose_lookup(
goto done;
}
- *out = git_reference__alloc_symbolic(backend->refdb, ref_name, target);
+ *out = git_reference__alloc_symbolic(ref_name, target);
} else {
if ((error = loose_parse_oid(&oid, &ref_file)) < 0)
goto done;
-
- *out = git_reference__alloc(backend->refdb, ref_name, &oid, NULL);
+
+ *out = git_reference__alloc(ref_name, &oid, NULL);
}
if (*out == NULL)
@@ -456,19 +456,19 @@ static int packed_map_entry(
if (packed_load(backend) < 0)
return -1;
-
+
/* Look up on the packfile */
packfile_refs = backend->refcache.packfile;
*pos = git_strmap_lookup_index(packfile_refs, ref_name);
-
+
if (!git_strmap_valid_index(packfile_refs, *pos)) {
giterr_set(GITERR_REFERENCE, "Reference '%s' not found", ref_name);
return GIT_ENOTFOUND;
}
*entry = git_strmap_value_at(packfile_refs, *pos);
-
+
return 0;
}
@@ -480,14 +480,14 @@ static int packed_lookup(
struct packref *entry;
khiter_t pos;
int error = 0;
-
+
if ((error = packed_map_entry(&entry, &pos, backend, ref_name)) < 0)
return error;
- if ((*out = git_reference__alloc(backend->refdb, ref_name,
+ if ((*out = git_reference__alloc(ref_name,
&entry->oid, &entry->peel)) == NULL)
return -1;
-
+
return 0;
}
@@ -583,7 +583,7 @@ static int refdb_fs_backend__foreach(
git_buf refs_path = GIT_BUF_INIT;
const char *ref_name;
void *ref = NULL;
-
+
GIT_UNUSED(ref);
assert(_backend);
@@ -591,7 +591,7 @@ static int refdb_fs_backend__foreach(
if (packed_load(backend) < 0)
return -1;
-
+
/* list all the packed references first */
if (list_type & GIT_REF_OID) {
git_strmap_foreach(backend->refcache.packfile, ref_name, ref, {
@@ -925,7 +925,7 @@ static int refdb_fs_backend__delete(
repo = backend->repo;
/* If a loose reference exists, remove it from the filesystem */
-
+
if (git_buf_joinpath(&loose_path, repo->path_repository, ref->name) < 0)
return -1;
@@ -933,7 +933,7 @@ static int refdb_fs_backend__delete(
error = p_unlink(loose_path.ptr);
loose_deleted = 1;
}
-
+
git_buf_free(&loose_path);
if (error != 0)
@@ -947,7 +947,7 @@ static int refdb_fs_backend__delete(
error = packed_write(backend);
}
-
+
if (pack_error == GIT_ENOTFOUND)
error = loose_deleted ? 0 : GIT_ENOTFOUND;
else
@@ -999,8 +999,7 @@ static void refdb_fs_backend__free(git_refdb_backend *_backend)
int git_refdb_backend_fs(
git_refdb_backend **backend_out,
- git_repository *repository,
- git_refdb *refdb)
+ git_repository *repository)
{
refdb_fs_backend *backend;
@@ -1009,7 +1008,6 @@ int git_refdb_backend_fs(
backend->repo = repository;
backend->path = repository->path_repository;
- backend->refdb = refdb;
backend->parent.exists = &refdb_fs_backend__exists;
backend->parent.lookup = &refdb_fs_backend__lookup;