diff options
| author | Vicent Marti <tanoku@gmail.com> | 2011-02-28 12:12:26 +0200 |
|---|---|---|
| committer | Vicent Marti <tanoku@gmail.com> | 2011-03-03 20:23:52 +0200 |
| commit | 5de079b86dcf8744f71fa3d0bb496a2cf9b20c0d (patch) | |
| tree | 3bfac650e63c3d924d0e64638d1254fc4ee13f63 /src/git2 | |
| parent | 3dccfed16382c64370dd0fd88668c9d9accae6ed (diff) | |
| download | libgit2-5de079b86dcf8744f71fa3d0bb496a2cf9b20c0d.tar.gz | |
Change the object creation/lookup API
The methods previously known as
git_repository_lookup
git_repository_newobject
git_repository_lookup_ref
are now part of their respective namespaces:
git_object_lookup
git_object_new
git_reference_lookup
This makes the API more consistent with the new references API.
Signed-off-by: Vicent Marti <tanoku@gmail.com>
Diffstat (limited to 'src/git2')
| -rw-r--r-- | src/git2/blob.h | 6 | ||||
| -rw-r--r-- | src/git2/commit.h | 6 | ||||
| -rw-r--r-- | src/git2/object.h | 43 | ||||
| -rw-r--r-- | src/git2/refs.h | 13 | ||||
| -rw-r--r-- | src/git2/repository.h | 59 | ||||
| -rw-r--r-- | src/git2/tag.h | 6 | ||||
| -rw-r--r-- | src/git2/tree.h | 6 |
7 files changed, 68 insertions, 71 deletions
diff --git a/src/git2/blob.h b/src/git2/blob.h index b34b5bfe9..b527d61f4 100644 --- a/src/git2/blob.h +++ b/src/git2/blob.h @@ -28,7 +28,7 @@ #include "common.h" #include "types.h" #include "oid.h" -#include "repository.h" +#include "object.h" /** * @file git2/blob.h @@ -51,7 +51,7 @@ GIT_BEGIN_DECL */ 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); + return git_object_lookup((git_object **)blob, repo, id, GIT_OBJ_BLOB); } /** @@ -67,7 +67,7 @@ GIT_INLINE(int) git_blob_lookup(git_blob **blob, git_repository *repo, const git */ GIT_INLINE(int) git_blob_new(git_blob **blob, git_repository *repo) { - return git_repository_newobject((git_object **)blob, repo, GIT_OBJ_BLOB); + return git_object_new((git_object **)blob, repo, GIT_OBJ_BLOB); } /** diff --git a/src/git2/commit.h b/src/git2/commit.h index 4d0b2ab99..21836dbbd 100644 --- a/src/git2/commit.h +++ b/src/git2/commit.h @@ -28,7 +28,7 @@ #include "common.h" #include "types.h" #include "oid.h" -#include "repository.h" +#include "object.h" /** * @file git2/commit.h @@ -52,7 +52,7 @@ GIT_BEGIN_DECL */ 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); + return git_object_lookup((git_object **)commit, repo, id, GIT_OBJ_COMMIT); } /** @@ -68,7 +68,7 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con */ GIT_INLINE(int) git_commit_new(git_commit **commit, git_repository *repo) { - return git_repository_newobject((git_object **)commit, repo, GIT_OBJ_COMMIT); + return git_object_new((git_object **)commit, repo, GIT_OBJ_COMMIT); } /** diff --git a/src/git2/object.h b/src/git2/object.h index 128c9faf5..80477d44a 100644 --- a/src/git2/object.h +++ b/src/git2/object.h @@ -39,6 +39,49 @@ GIT_BEGIN_DECL /** + * Lookup a reference to one of the objects in a repostory. + * + * The generated reference is owned by the repository and + * should not be freed by the user. + * + * The 'type' parameter must match the type of the object + * in the odb; the method will fail otherwise. + * The special value 'GIT_OBJ_ANY' may be passed to let + * the method guess the object's type. + * + * @param object pointer to the looked-up object + * @param repo the repository to look up the object + * @param id the unique identifier for the object + * @param type the type of the object + * @return a reference to the object + */ +GIT_EXTERN(int) git_object_lookup(git_object **object, git_repository *repo, const git_oid *id, git_otype type); + +/** + * Create a new in-memory repository object with + * the given type. + * + * The object's attributes can be filled in using the + * corresponding setter methods. + * + * The object will be written back to given git_repository + * when the git_object_write() function is called; objects + * cannot be written to disk until all their main + * attributes have been properly filled. + * + * Objects are instantiated with no SHA1 id; their id + * will be automatically generated when writing to the + * repository. + * + * @param object pointer to the new object + * @parem repo Repository where the object belongs + * @param type Type of the object to be created + * @return the new object + */ +GIT_EXTERN(int) git_object_new(git_object **object, git_repository *repo, git_otype type); + + +/** * Write back an object to disk. * * The object will be written to its corresponding diff --git a/src/git2/refs.h b/src/git2/refs.h index 752d80862..1702d7ee1 100644 --- a/src/git2/refs.h +++ b/src/git2/refs.h @@ -39,6 +39,19 @@ GIT_BEGIN_DECL /** + * Lookup a reference by its name in a repository. + * + * The generated reference is owned by the repository and + * should not be freed by the user. + * + * @param reference_out pointer to the looked-up reference + * @param repo the repository to look up the reference + * @param name the long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, ...) + * @return 0 on success; error code otherwise + */ +GIT_EXTERN(int) git_reference_lookup(git_reference **reference_out, git_repository *repo, const char *name); + +/** * Create a new symbolic reference. * * The reference will be created in the repository and written diff --git a/src/git2/repository.h b/src/git2/repository.h index ec74305ae..dbb9dddef 100644 --- a/src/git2/repository.h +++ b/src/git2/repository.h @@ -132,26 +132,6 @@ GIT_EXTERN(int) git_repository_open3(git_repository **repository, const char *git_index_file, const char *git_work_tree); - -/** - * Lookup a reference to one of the objects in the repostory. - * - * The generated reference is owned by the repository and - * should not be freed by the user. - * - * The 'type' parameter must match the type of the object - * in the odb; the method will fail otherwise. - * The special value 'GIT_OBJ_ANY' may be passed to let - * the method guess the object's type. - * - * @param object pointer to the looked-up object - * @param repo the repository to look up the object - * @param id the unique identifier for the object - * @param type the type of the object - * @return a reference to the object - */ -GIT_EXTERN(int) git_repository_lookup(git_object **object, git_repository *repo, const git_oid *id, git_otype type); - /** * Get the object database behind a Git repository * @@ -173,29 +153,6 @@ GIT_EXTERN(git_odb *) git_repository_database(git_repository *repo); GIT_EXTERN(int) git_repository_index(git_index **index, git_repository *repo); /** - * Create a new in-memory repository object with - * the given type. - * - * The object's attributes can be filled in using the - * corresponding setter methods. - * - * The object will be written back to given git_repository - * when the git_object_write() function is called; objects - * cannot be written to disk until all their main - * attributes have been properly filled. - * - * Objects are instantiated with no SHA1 id; their id - * will be automatically generated when writing to the - * repository. - * - * @param object pointer to the new object - * @parem repo Repository where the object belongs - * @param type Type of the object to be created - * @return the new object - */ -GIT_EXTERN(int) git_repository_newobject(git_object **object, git_repository *repo, git_otype type); - -/** * Free a previously allocated repository * @param repo repository handle to close. If NULL nothing occurs. */ @@ -218,22 +175,6 @@ GIT_EXTERN(void) git_repository_free(git_repository *repo); */ GIT_EXTERN(int) git_repository_init(git_repository **repo_out, const char *path, unsigned is_bare); -/** - * Lookup a reference by its name in the repository. - * - * The generated reference is owned by the repository and - * should not be freed by the user. - * - * TODO: - * - Ensure the reference name is valid - * - * @param reference_out pointer to the looked-up reference - * @param repo the repository to look up the reference - * @param name the long name for the reference (e.g. HEAD, ref/heads/master, refs/tags/v0.1.0, ...) - * @return a reference to the reference - */ -GIT_EXTERN(int) git_repository_lookup_ref(git_reference **reference_out, git_repository *repo, const char *name); - /** @} */ GIT_END_DECL #endif diff --git a/src/git2/tag.h b/src/git2/tag.h index 4fd6ea980..2ca25c8a0 100644 --- a/src/git2/tag.h +++ b/src/git2/tag.h @@ -28,7 +28,7 @@ #include "common.h" #include "types.h" #include "oid.h" -#include "repository.h" +#include "object.h" /** * @file git2/tag.h @@ -51,7 +51,7 @@ GIT_BEGIN_DECL */ 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_otype)GIT_OBJ_TAG); + return git_object_lookup((git_object **)tag, repo, id, (git_otype)GIT_OBJ_TAG); } /** @@ -67,7 +67,7 @@ GIT_INLINE(int) git_tag_lookup(git_tag **tag, git_repository *repo, const git_oi */ GIT_INLINE(int) git_tag_new(git_tag **tag, git_repository *repo) { - return git_repository_newobject((git_object **)tag, repo, (git_otype)GIT_OBJ_TAG); + return git_object_new((git_object **)tag, repo, (git_otype)GIT_OBJ_TAG); } /** diff --git a/src/git2/tree.h b/src/git2/tree.h index 20c367574..70040f058 100644 --- a/src/git2/tree.h +++ b/src/git2/tree.h @@ -28,7 +28,7 @@ #include "common.h" #include "types.h" #include "oid.h" -#include "repository.h" +#include "object.h" /** * @file git2/tree.h @@ -51,7 +51,7 @@ GIT_BEGIN_DECL */ 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); + return git_object_lookup((git_object **)tree, repo, id, GIT_OBJ_TREE); } /** @@ -67,7 +67,7 @@ GIT_INLINE(int) git_tree_lookup(git_tree **tree, git_repository *repo, const git */ GIT_INLINE(int) git_tree_new(git_tree **tree, git_repository *repo) { - return git_repository_newobject((git_object **)tree, repo, GIT_OBJ_TREE); + return git_object_new((git_object **)tree, repo, GIT_OBJ_TREE); } /** |
