]> git.proxmox.com Git - libgit2.git/commitdiff
Add methods to access internal attributes in git_repo
authorVicent Marti <tanoku@gmail.com>
Sun, 12 Sep 2010 20:43:21 +0000 (23:43 +0300)
committerVicent Marti <tanoku@gmail.com>
Sun, 12 Sep 2010 20:43:21 +0000 (23:43 +0300)
Added several methods to access:

- The ODB behind a repo
- The SHA1 id behind a generic repo object
- The type of a generic repo object

Signed-off-by: Vicent Marti <tanoku@gmail.com>
src/git/repository.h
src/repository.c

index 001e4e9fb8e266b868e1bbc4475568bc37b16648..a61e5b6cc8ecdd82e5c0de6825ad5c61c1585472 100644 (file)
@@ -49,6 +49,29 @@ GIT_EXTERN(git_repository *) git_repository_alloc(git_odb *odb);
  */
 GIT_EXTERN(git_repository_object *) git_repository_lookup(git_repository *repo, const git_oid *id, git_otype type);
 
+/**
+ * Get the object database behind a Git repository
+ *
+ * @param repo a repository object
+ * @return a pointer to the object db
+ */
+GIT_EXTERN(git_odb *) git_repository_database(git_repository *repo);
+
+/**
+ * Get the id (SHA1) of a repository object
+ *
+ * @param obj the repository object
+ * @return the SHA1 id
+ */
+const git_oid *git_repository_object_id(git_repository_object *obj);
+
+/**
+ * Get the object type of an object
+ *
+ * @param obj the repository object
+ * @return the object's type
+ */
+git_otype git_repository_object_type(git_repository_object *obj);
 
 /**
  * Free a reference to one of the objects in the repostory.
index 86f2216cb6f8701976d2f627c180a91887f959d8..3f07bd608a12f40db636146509e27a7847b0211e 100644 (file)
@@ -138,6 +138,24 @@ void git_repository_object_free(git_repository_object *object)
        }
 }
 
+git_odb *git_repository_database(git_repository *repo)
+{
+       assert(repo);
+       return repo->db;
+}
+
+const git_oid *git_repository_object_id(git_repository_object *obj)
+{
+       assert(obj);
+       return &obj->id;
+}
+
+git_otype git_repository_object_type(git_repository_object *obj)
+{
+       assert(obj);
+       return obj->dbo.type;
+}
+
 git_repository_object *git_repository_lookup(git_repository *repo, const git_oid *id, git_otype type)
 {
        static const size_t object_sizes[] = {