diff options
author | Vicent Marti <tanoku@gmail.com> | 2011-01-03 22:34:27 +0200 |
---|---|---|
committer | Vicent Marti <tanoku@gmail.com> | 2011-01-03 22:34:27 +0200 |
commit | e52ed7a5595568f169b3df74b675059c3d04da4a (patch) | |
tree | 343dd106eeb770a4e3e68759c681a096469ba70a /src/git2 | |
parent | fb3cd6bca40ef942898e9d5ae5d9f305deefcc40 (diff) | |
download | libgit2-e52ed7a5595568f169b3df74b675059c3d04da4a.tar.gz |
Split object methods from repository.c
All the relevant git_object methods have been moved to object.c
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/git2')
-rw-r--r-- | src/git2/blob.h | 11 | ||||
-rw-r--r-- | src/git2/commit.h | 11 | ||||
-rw-r--r-- | src/git2/object.h | 14 | ||||
-rw-r--r-- | src/git2/tag.h | 11 | ||||
-rw-r--r-- | src/git2/tree.h | 11 |
5 files changed, 50 insertions, 8 deletions
diff --git a/src/git2/blob.h b/src/git2/blob.h index 9c7b5a2a9..b34b5bfe9 100644 --- a/src/git2/blob.h +++ b/src/git2/blob.h @@ -28,6 +28,7 @@ #include "common.h" #include "types.h" #include "oid.h" +#include "repository.h" /** * @file git2/blob.h @@ -48,7 +49,10 @@ GIT_BEGIN_DECL * @param id identity of the blob to locate. * @return 0 on success; error code otherwise */ -GIT_EXTERN(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id); +GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git_oid *id) +{ + return git_repository_lookup((git_object **)blob, repo, id, GIT_OBJ_BLOB); +} /** * Create a new in-memory git_blob. @@ -61,7 +65,10 @@ GIT_EXTERN(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git * @param repo The repository where the object will reside * @return 0 on success; error code otherwise */ -GIT_EXTERN(int) git_blob_new(git_blob **blob, git_repository *repo); +GIT_INLINE(int) git_blob_new(git_blob **blob, git_repository *repo) +{ + return git_repository_newobject((git_object **)blob, repo, GIT_OBJ_BLOB); +} /** * Fill a blob with the contents inside diff --git a/src/git2/commit.h b/src/git2/commit.h index ccffec45f..328f78ada 100644 --- a/src/git2/commit.h +++ b/src/git2/commit.h @@ -28,6 +28,7 @@ #include "common.h" #include "types.h" #include "oid.h" +#include "repository.h" /** * @file git2/commit.h @@ -49,7 +50,10 @@ GIT_BEGIN_DECL * an annotated tag it will be peeled back to the commit. * @return 0 on success; error code otherwise */ -GIT_EXTERN(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id); +GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id) +{ + return git_repository_lookup((git_object **)commit, repo, id, GIT_OBJ_COMMIT); +} /** * Create a new in-memory git_commit. @@ -62,7 +66,10 @@ GIT_EXTERN(int) git_commit_lookup(git_commit **commit, git_repository *repo, con * @param repo The repository where the object will reside * @return 0 on success; error code otherwise */ -GIT_EXTERN(int) git_commit_new(git_commit ** commit, git_repository *repo); +GIT_INLINE(int) git_commit_new(git_commit **commit, git_repository *repo) +{ + return git_repository_newobject((git_object **)commit, repo, GIT_OBJ_COMMIT); +} /** * Get the id of a commit. diff --git a/src/git2/object.h b/src/git2/object.h index f316c5d62..084d11177 100644 --- a/src/git2/object.h +++ b/src/git2/object.h @@ -126,6 +126,20 @@ GIT_EXTERN(git_otype) git_object_string2type(const char *str); */ GIT_EXTERN(int) git_object_typeisloose(git_otype type); +/** + * Get the size in bytes for the structure which + * acts as an in-memory representation of any given + * object type. + * + * For all the core types, this would the equivalent + * of calling `sizeof(git_commit)` if the core types + * were not opaque on the external API. + * + * @param type object type to get its size + * @return size in bytes of the object + */ +GIT_EXTERN(size_t) git_object__size(git_otype type); + /** @} */ GIT_END_DECL diff --git a/src/git2/tag.h b/src/git2/tag.h index 8e29bc14a..e97c2badd 100644 --- a/src/git2/tag.h +++ b/src/git2/tag.h @@ -28,6 +28,7 @@ #include "common.h" #include "types.h" #include "oid.h" +#include "repository.h" /** * @file git2/tag.h @@ -48,7 +49,10 @@ GIT_BEGIN_DECL * @param id identity of the tag to locate. * @return 0 on success; error code otherwise */ -GIT_EXTERN(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oid *id); +GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oid *id) +{ + return git_repository_lookup((git_object **)tag, repo, id, GIT_OBJ_TAG); +} /** * Create a new in-memory git_tag. @@ -61,7 +65,10 @@ GIT_EXTERN(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oi * @param repo The repository where the object will reside * @return 0 on success; error code otherwise */ -GIT_EXTERN(int) git_tag_new(git_tag **tag, git_repository *repo); +GIT_INLINE(int) git_tag_new(git_tag **tag, git_repository *repo) +{ + return git_repository_newobject((git_object **)tag, repo, GIT_OBJ_TAG); +} /** * Get the id of a tag. diff --git a/src/git2/tree.h b/src/git2/tree.h index b2f6905ae..3e003de64 100644 --- a/src/git2/tree.h +++ b/src/git2/tree.h @@ -28,6 +28,7 @@ #include "common.h" #include "types.h" #include "oid.h" +#include "repository.h" /** * @file git2/tree.h @@ -48,7 +49,10 @@ GIT_BEGIN_DECL * @param id identity of the tree to locate. * @return 0 on success; error code otherwise */ -GIT_EXTERN(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git_oid *id); +GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git_oid *id) +{ + return git_repository_lookup((git_object **)tree, repo, id, GIT_OBJ_TREE); +} /** * Create a new in-memory git_tree. @@ -61,7 +65,10 @@ GIT_EXTERN(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git * @param repo The repository where the object will reside * @return 0 on success; error code otherwise */ -GIT_EXTERN(int) git_tree_new(git_tree **tree, git_repository *repo); +GIT_INLINE(int) git_tree_new(git_tree **tree, git_repository *repo) +{ + return git_repository_newobject((git_object **)tree, repo, GIT_OBJ_TREE); +} /** * Get the id of a tree. |