Commit a13bc8e7 by Vicent Marti

Add getter methods for object owners

You can know access the owning repository of any existing object, or the
repository on which a revision walker is working on.

Signed-off-by: Vicent Marti <tanoku@gmail.com>
parent aaf68dc4
...@@ -96,7 +96,7 @@ GIT_EXTERN(git_object *) git_object_new(git_repository *repo, git_otype type); ...@@ -96,7 +96,7 @@ GIT_EXTERN(git_object *) git_object_new(git_repository *repo, git_otype type);
* @param object Git object to write back * @param object Git object to write back
* @return 0 on success; otherwise an error code * @return 0 on success; otherwise an error code
*/ */
int git_object_write(git_object *object); GIT_EXTERN(int) git_object_write(git_object *object);
/** /**
* Get the id (SHA1) of a repository object * Get the id (SHA1) of a repository object
...@@ -107,7 +107,7 @@ int git_object_write(git_object *object); ...@@ -107,7 +107,7 @@ int git_object_write(git_object *object);
* @param obj the repository object * @param obj the repository object
* @return the SHA1 id * @return the SHA1 id
*/ */
const git_oid *git_object_id(git_object *obj); GIT_EXTERN(const git_oid *) git_object_id(git_object *obj);
/** /**
* Get the object type of an object * Get the object type of an object
...@@ -115,7 +115,15 @@ const git_oid *git_object_id(git_object *obj); ...@@ -115,7 +115,15 @@ const git_oid *git_object_id(git_object *obj);
* @param obj the repository object * @param obj the repository object
* @return the object's type * @return the object's type
*/ */
git_otype git_object_type(git_object *obj); GIT_EXTERN(git_otype) git_object_type(git_object *obj);
/**
* Get the repository that owns this object
*
* @param obj the object
* @return the repository who owns this object
*/
GIT_EXTERN(git_repository *) git_object_owner(git_object *obj);
/** /**
* Free a reference to one of the objects in the repository. * Free a reference to one of the objects in the repository.
......
...@@ -97,6 +97,15 @@ GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode); ...@@ -97,6 +97,15 @@ GIT_EXTERN(void) git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode);
*/ */
GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk); GIT_EXTERN(void) git_revwalk_free(git_revwalk *walk);
/**
* Return the repository on which this walker
* is operating.
*
* @param walk the revision walker
* @return the repository being walked
*/
GIT_EXTERN(git_repository *) git_revwalk_repository(git_revwalk *walk);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL
#endif #endif
...@@ -333,6 +333,12 @@ git_otype git_object_type(git_object *obj) ...@@ -333,6 +333,12 @@ git_otype git_object_type(git_object *obj)
return obj->source.raw.type; return obj->source.raw.type;
} }
git_repository *git_object_owner(git_object *obj)
{
assert(obj);
return obj->repo;
}
git_object *git_object_new(git_repository *repo, git_otype type) git_object *git_object_new(git_repository *repo, git_otype type)
{ {
git_object *object = NULL; git_object *object = NULL;
......
...@@ -80,6 +80,12 @@ void git_revwalk_free(git_revwalk *walk) ...@@ -80,6 +80,12 @@ void git_revwalk_free(git_revwalk *walk)
free(walk); free(walk);
} }
git_repository *git_revwalk_repository(git_revwalk *walk)
{
assert(walk);
return walk->repo;
}
void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode) void git_revwalk_sorting(git_revwalk *walk, unsigned int sort_mode)
{ {
if (walk->walking) if (walk->walking)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment