Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
git2
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lvzhengyang
git2
Commits
0b726701
Commit
0b726701
authored
Apr 30, 2013
by
Vicent Marti
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
object: Explicitly define helper API methods for all obj types
parent
cd2ed9f0
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
133 additions
and
34 deletions
+133
-34
include/git2/commit.h
+4
-16
src/blob.c
+0
-2
src/object.h
+0
-12
src/object_api.c
+129
-0
src/tag.c
+0
-2
src/tree.c
+0
-2
No files found.
include/git2/commit.h
View file @
0b726701
...
@@ -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,
...
...
src/blob.c
View file @
0b726701
...
@@ -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
);
...
...
src/object.h
View file @
0b726701
...
@@ -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
src/object_api.c
0 → 100644
View file @
0b726701
/*
* 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
);
}
src/tag.c
View file @
0b726701
...
@@ -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
;
...
...
src/tree.c
View file @
0b726701
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment