diff options
author | Russell Belfer <rb@github.com> | 2013-04-21 12:52:17 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-04-21 12:52:17 -0700 |
commit | 21ca045100337bcb2905a20a72d42721d18871f9 (patch) | |
tree | 1db8654b2f7e2dd961d2f7fb3c9ea98c3d57cb61 /src | |
parent | 4dcd87801972e1b880afa9cd0998842bae7af5b5 (diff) | |
download | libgit2-21ca045100337bcb2905a20a72d42721d18871f9.tar.gz |
Move git_reference__alloc to include/git2/sys
Create a new include/git2/sys/refs.h and move the reference alloc
functions there. Also fix some documentation issues and some
minor code cleanups.
Diffstat (limited to 'src')
-rw-r--r-- | src/refdb.c | 28 | ||||
-rw-r--r-- | src/refdb.h | 2 | ||||
-rw-r--r-- | src/refdb_fs.c | 1 | ||||
-rw-r--r-- | src/refs.c | 4 |
4 files changed, 16 insertions, 19 deletions
diff --git a/src/refdb.c b/src/refdb.c index 0675be638..33a1934d1 100644 --- a/src/refdb.c +++ b/src/refdb.c @@ -58,15 +58,19 @@ int git_refdb_open(git_refdb **out, git_repository *repo) return 0; } -int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend) +static void refdb_free_backend(git_refdb *db) { if (db->backend) { - if(db->backend->free) + if (db->backend->free) db->backend->free(db->backend); else git__free(db->backend); } +} +int git_refdb_set_backend(git_refdb *db, git_refdb_backend *backend) +{ + refdb_free_backend(db); db->backend = backend; return 0; @@ -76,22 +80,15 @@ int git_refdb_compress(git_refdb *db) { assert(db); - if (db->backend->compress) { + if (db->backend->compress) return db->backend->compress(db->backend); - } return 0; } static void refdb_free(git_refdb *db) { - if (db->backend) { - if(db->backend->free) - db->backend->free(db->backend); - else - git__free(db->backend); - } - + refdb_free_backend(db); git__free(db); } @@ -115,14 +112,13 @@ int git_refdb_lookup(git_reference **out, git_refdb *db, const char *ref_name) git_reference *ref; int error; - assert(db && db->backend && ref_name); - - *out = NULL; + assert(db && db->backend && out && ref_name); - if ((error = db->backend->lookup(&ref, db->backend, ref_name)) == 0) - { + if (!(error = db->backend->lookup(&ref, db->backend, ref_name))) { ref->db = db; *out = ref; + } else { + *out = NULL; } return error; diff --git a/src/refdb.h b/src/refdb.h index 0969711b9..047113ac8 100644 --- a/src/refdb.h +++ b/src/refdb.h @@ -41,6 +41,6 @@ int git_refdb_foreach_glob( int git_refdb_write(git_refdb *refdb, const git_reference *ref); -int git_refdb_delete(struct git_refdb *refdb, const git_reference *ref); +int git_refdb_delete(git_refdb *refdb, const git_reference *ref); #endif diff --git a/src/refdb_fs.c b/src/refdb_fs.c index 4d5d6006d..443871005 100644 --- a/src/refdb_fs.c +++ b/src/refdb_fs.c @@ -19,6 +19,7 @@ #include <git2/object.h> #include <git2/refdb.h> #include <git2/sys/refdb_backend.h> +#include <git2/sys/refs.h> GIT__USE_STRMAP; diff --git a/src/refs.c b/src/refs.c index d9291e56f..9c6684a5a 100644 --- a/src/refs.c +++ b/src/refs.c @@ -19,6 +19,7 @@ #include <git2/branch.h> #include <git2/refs.h> #include <git2/refdb.h> +#include <git2/sys/refs.h> GIT__USE_STRMAP; @@ -44,8 +45,7 @@ static git_reference *alloc_ref(const char *name) } git_reference *git_reference__alloc_symbolic( - const char *name, - const char *target) + const char *name, const char *target) { git_reference *ref; |