Commit 0b726701 by Vicent Marti

object: Explicitly define helper API methods for all obj types

parent cd2ed9f0
...@@ -30,10 +30,7 @@ GIT_BEGIN_DECL ...@@ -30,10 +30,7 @@ GIT_BEGIN_DECL
* an annotated tag it will be peeled back to the commit. * an annotated tag it will be peeled back to the commit.
* @return 0 or an error code * @return 0 or an error code
*/ */
GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id) GIT_EXTERN(int) git_commit_lookup(git_commit **commit, git_repository *repo, const git_oid *id);
{
return git_object_lookup((git_object **)commit, repo, id, GIT_OBJ_COMMIT);
}
/** /**
* Lookup a commit object from a repository, * Lookup a commit object from a repository,
...@@ -48,10 +45,7 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con ...@@ -48,10 +45,7 @@ GIT_INLINE(int) git_commit_lookup(git_commit **commit, git_repository *repo, con
* @param len the length of the short identifier * @param len the length of the short identifier
* @return 0 or an error code * @return 0 or an error code
*/ */
GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *repo, const git_oid *id, size_t len) GIT_EXTERN(int) git_commit_lookup_prefix(git_commit **commit, git_repository *repo, const git_oid *id, size_t len);
{
return git_object_lookup_prefix((git_object **)commit, repo, id, len, GIT_OBJ_COMMIT);
}
/** /**
* Close an open commit * Close an open commit
...@@ -65,10 +59,7 @@ GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *re ...@@ -65,10 +59,7 @@ GIT_INLINE(int) git_commit_lookup_prefix(git_commit **commit, git_repository *re
* @param commit the commit to close * @param commit the commit to close
*/ */
GIT_INLINE(void) git_commit_free(git_commit *commit) GIT_EXTERN(void) git_commit_free(git_commit *commit);
{
git_object_free((git_object *) commit);
}
/** /**
* Get the id of a commit. * Get the id of a commit.
...@@ -76,10 +67,7 @@ GIT_INLINE(void) git_commit_free(git_commit *commit) ...@@ -76,10 +67,7 @@ GIT_INLINE(void) git_commit_free(git_commit *commit)
* @param commit a previously loaded commit. * @param commit a previously loaded commit.
* @return object identity for the commit. * @return object identity for the commit.
*/ */
GIT_INLINE(const git_oid *) git_commit_id(const git_commit *commit) GIT_EXTERN(const git_oid *) git_commit_id(const git_commit *commit);
{
return git_object_id((const git_object *)commit);
}
/** /**
* Get the encoding for the message of a commit, * Get the encoding for the message of a commit,
......
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include "filter.h" #include "filter.h"
#include "buf_text.h" #include "buf_text.h"
GIT_OBJECT__TYPED_FUNCTIONS(git_blob, GIT_OBJ_BLOB)
const void *git_blob_rawcontent(const git_blob *blob) const void *git_blob_rawcontent(const git_blob *blob)
{ {
assert(blob); assert(blob);
......
...@@ -28,16 +28,4 @@ int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end ...@@ -28,16 +28,4 @@ int git_oid__parse(git_oid *oid, const char **buffer_out, const char *buffer_end
void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid); void git_oid__writebuf(git_buf *buf, const char *header, const git_oid *oid);
#define GIT_OBJECT__TYPED_FUNCTIONS(TYPE,OBJTYPE) \
int TYPE##_lookup(TYPE **out, git_repository *repo, const git_oid *id) { \
return git_object_lookup((git_object **)out, repo, id, OBJTYPE); } \
int TYPE##_lookup_prefix(TYPE **out, git_repository *repo, const git_oid *id, size_t len) { \
return git_object_lookup_prefix((git_object **)out, repo, id, len, OBJTYPE); } \
void TYPE##_free(TYPE *obj) { \
git_object_free((git_object *)obj); } \
const git_oid *TYPE##_id(const TYPE *obj) { \
return git_object_id((const git_object *)obj); } \
git_repository *TYPE##_owner(const TYPE *obj) { \
return git_object_owner((const git_object *)obj); }
#endif #endif
/*
* Copyright (C) the libgit2 contributors. All rights reserved.
*
* This file is part of libgit2, distributed under the GNU GPL v2 with
* a Linking Exception. For full terms see the included COPYING file.
*/
#include "git2/object.h"
#include "common.h"
#include "repository.h"
#include "commit.h"
#include "tree.h"
#include "blob.h"
#include "tag.h"
/**
* Blob
*/
int git_commit_lookup(git_commit **out, git_repository *repo, const git_oid *id)
{
return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_COMMIT);
}
int git_commit_lookup_prefix(git_commit **out, git_repository *repo, const git_oid *id, size_t len)
{
return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_COMMIT);
}
void git_commit_free(git_commit *obj)
{
git_object_free((git_object *)obj);
}
const git_oid *git_commit_id(const git_commit *obj)
{
return git_object_id((const git_object *)obj);
}
git_repository *git_commit_owner(const git_commit *obj)
{
return git_object_owner((const git_object *)obj);
}
/**
* Tree
*/
int git_tree_lookup(git_tree **out, git_repository *repo, const git_oid *id)
{
return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_COMMIT);
}
int git_tree_lookup_prefix(git_tree **out, git_repository *repo, const git_oid *id, size_t len)
{
return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_COMMIT);
}
void git_tree_free(git_tree *obj)
{
git_object_free((git_object *)obj);
}
const git_oid *git_tree_id(const git_tree *obj)
{
return git_object_id((const git_object *)obj);
}
git_repository *git_tree_owner(const git_tree *obj)
{
return git_object_owner((const git_object *)obj);
}
/**
* Tag
*/
int git_tag_lookup(git_tag **out, git_repository *repo, const git_oid *id)
{
return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_COMMIT);
}
int git_tag_lookup_prefix(git_tag **out, git_repository *repo, const git_oid *id, size_t len)
{
return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_COMMIT);
}
void git_tag_free(git_tag *obj)
{
git_object_free((git_object *)obj);
}
const git_oid *git_tag_id(const git_tag *obj)
{
return git_object_id((const git_object *)obj);
}
git_repository *git_tag_owner(const git_tag *obj)
{
return git_object_owner((const git_object *)obj);
}
/**
* Blob
*/
int git_blob_lookup(git_blob **out, git_repository *repo, const git_oid *id)
{
return git_object_lookup((git_object **)out, repo, id, GIT_OBJ_COMMIT);
}
int git_blob_lookup_prefix(git_blob **out, git_repository *repo, const git_oid *id, size_t len)
{
return git_object_lookup_prefix((git_object **)out, repo, id, len, GIT_OBJ_COMMIT);
}
void git_blob_free(git_blob *obj)
{
git_object_free((git_object *)obj);
}
const git_oid *git_blob_id(const git_blob *obj)
{
return git_object_id((const git_object *)obj);
}
git_repository *git_blob_owner(const git_blob *obj)
{
return git_object_owner((const git_object *)obj);
}
...@@ -15,8 +15,6 @@ ...@@ -15,8 +15,6 @@
#include "git2/signature.h" #include "git2/signature.h"
#include "git2/odb_backend.h" #include "git2/odb_backend.h"
GIT_OBJECT__TYPED_FUNCTIONS(git_tag, GIT_OBJ_TAG)
void git_tag__free(void *_tag) void git_tag__free(void *_tag)
{ {
git_tag *tag = _tag; git_tag *tag = _tag;
......
...@@ -11,8 +11,6 @@ ...@@ -11,8 +11,6 @@
#include "git2/repository.h" #include "git2/repository.h"
#include "git2/object.h" #include "git2/object.h"
GIT_OBJECT__TYPED_FUNCTIONS(git_tree, GIT_OBJ_TREE)
#define DEFAULT_TREE_SIZE 16 #define DEFAULT_TREE_SIZE 16
#define MAX_FILEMODE_BYTES 6 #define MAX_FILEMODE_BYTES 6
......
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