summaryrefslogtreecommitdiff
path: root/src/backends/sqlite.c
diff options
context:
space:
mode:
authorMarc Pegon <pegon.marc@gmail.com>2011-05-27 18:49:09 +0200
committerVicent Marti <tanoku@gmail.com>2011-06-01 23:40:41 +0200
commitecd6fdf1f70b785f24e2d17bec516ac88be0cf2c (patch)
treeba9613519281aaffa48088f4bb4e0d1125e4c88e /src/backends/sqlite.c
parent4a51e9981469c883225f774715d987bce2d41ee2 (diff)
downloadlibgit2-ecd6fdf1f70b785f24e2d17bec516ac88be0cf2c.tar.gz
Added a read_unique_short_oid method to backends, to make it possible to find objects from sha1 prefixes in the future. Default implementations throw GIT_ENOTIMPLEMENTED for strict prefixes (i.e. length < GIT_OID_HEXSZ).
Diffstat (limited to 'src/backends/sqlite.c')
-rw-r--r--src/backends/sqlite.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/backends/sqlite.c b/src/backends/sqlite.c
index abf14f180..c9c3b8049 100644
--- a/src/backends/sqlite.c
+++ b/src/backends/sqlite.c
@@ -103,6 +103,21 @@ int sqlite_backend__read(void **data_p, size_t *len_p, git_otype *type_p, git_od
return error == GIT_SUCCESS ? GIT_SUCCESS : git__rethrow(error, "SQLite backend: Failed to read");
}
+int sqlite_backend__read_unique_short_oid(git_oid *out_oid, void **data_p, size_t *len_p, git_otype *type_p, git_odb_backend *_backend,
+ const git_oid *short_oid, unsigned int len) {
+ if (len >= GIT_OID_HEXSZ) {
+ /* Just match the full identifier */
+ int error = sqlite_backend__read(data_p, len_p, type_p, _backend, short_oid);
+ if (error == GIT_SUCCESS)
+ git_oid_cpy(out_oid, short_oid);
+
+ return error;
+ } else if (len < GIT_OID_HEXSZ) {
+ /* TODO */
+ return git__throw(GIT_ENOTIMPLEMENTED, "Sqlite backend cannot search objects from short oid");
+ }
+}
+
int sqlite_backend__exists(git_odb_backend *_backend, const git_oid *oid)
{
sqlite_backend *backend;
@@ -255,6 +270,7 @@ int git_odb_backend_sqlite(git_odb_backend **backend_out, const char *sqlite_db)
goto cleanup;
backend->parent.read = &sqlite_backend__read;
+ backend->parent.read_unique_short_oid = &sqlite_backend__read_unique_short_oid;
backend->parent.read_header = &sqlite_backend__read_header;
backend->parent.write = &sqlite_backend__write;
backend->parent.exists = &sqlite_backend__exists;