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
f0224772
Commit
f0224772
authored
Feb 17, 2016
by
Edward Thomson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
git_object_dup: introduce typesafe versions
parent
684b35c4
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
59 additions
and
5 deletions
+59
-5
include/git2/blob.h
+9
-0
include/git2/commit.h
+9
-0
include/git2/tag.h
+9
-0
include/git2/tree.h
+9
-0
src/commit.c
+1
-1
src/describe.c
+1
-1
src/iterator.c
+2
-2
src/object_api.c
+19
-1
No files found.
include/git2/blob.h
View file @
f0224772
...
...
@@ -259,6 +259,15 @@ GIT_EXTERN(int) git_blob_create_frombuffer(
*/
GIT_EXTERN
(
int
)
git_blob_is_binary
(
const
git_blob
*
blob
);
/**
* Create an in-memory copy of a blob. The copy must be explicitly
* free'd or it will leak.
*
* @param out Pointer to store the copy of the object
* @param source Original object to copy
*/
GIT_EXTERN
(
int
)
git_blob_dup
(
git_blob
**
out
,
git_blob
*
source
);
/** @} */
GIT_END_DECL
#endif
include/git2/commit.h
View file @
f0224772
...
...
@@ -461,6 +461,15 @@ GIT_EXTERN(int) git_commit_create_with_signature(
const
char
*
signature
,
const
char
*
signature_field
);
/**
* Create an in-memory copy of a commit. The copy must be explicitly
* free'd or it will leak.
*
* @param out Pointer to store the copy of the commit
* @param source Original commit to copy
*/
GIT_EXTERN
(
int
)
git_commit_dup
(
git_commit
**
out
,
git_commit
*
source
);
/** @} */
GIT_END_DECL
#endif
include/git2/tag.h
View file @
f0224772
...
...
@@ -347,6 +347,15 @@ GIT_EXTERN(int) git_tag_peel(
git_object
**
tag_target_out
,
const
git_tag
*
tag
);
/**
* Create an in-memory copy of a tag. The copy must be explicitly
* free'd or it will leak.
*
* @param out Pointer to store the copy of the tag
* @param source Original tag to copy
*/
GIT_EXTERN
(
int
)
git_tag_dup
(
git_tag
**
out
,
git_tag
*
source
);
/** @} */
GIT_END_DECL
#endif
include/git2/tree.h
View file @
f0224772
...
...
@@ -409,6 +409,15 @@ GIT_EXTERN(int) git_tree_walk(
git_treewalk_cb
callback
,
void
*
payload
);
/**
* Create an in-memory copy of a tree. The copy must be explicitly
* free'd or it will leak.
*
* @param out Pointer to store the copy of the tree
* @param source Original tree to copy
*/
GIT_EXTERN
(
int
)
git_tree_dup
(
git_tree
**
out
,
git_tree
*
source
);
/** @} */
GIT_END_DECL
...
...
src/commit.c
View file @
f0224772
...
...
@@ -615,7 +615,7 @@ int git_commit_nth_gen_ancestor(
assert
(
ancestor
&&
commit
);
if
(
git_
object_dup
((
git_object
**
)
&
current
,
(
git_object
*
)
commit
)
<
0
)
if
(
git_
commit_dup
(
&
current
,
(
git_commit
*
)
commit
)
<
0
)
return
-
1
;
if
(
n
==
0
)
{
...
...
src/describe.c
View file @
f0224772
...
...
@@ -197,7 +197,7 @@ static int commit_name_dup(struct commit_name **out, struct commit_name *in)
name
->
tag
=
NULL
;
name
->
path
=
NULL
;
if
(
in
->
tag
&&
git_
object_dup
((
git_object
**
)
&
name
->
tag
,
(
git_object
*
)
in
->
tag
)
<
0
)
if
(
in
->
tag
&&
git_
tag_dup
(
&
name
->
tag
,
in
->
tag
)
<
0
)
return
-
1
;
name
->
path
=
git__strdup
(
in
->
path
);
...
...
src/iterator.c
View file @
f0224772
...
...
@@ -820,7 +820,7 @@ int git_iterator_for_tree(
if
(
tree
==
NULL
)
return
git_iterator_for_nothing
(
iter
,
options
);
if
((
error
=
git_
object_dup
((
git_object
**
)
&
tree
,
(
git_object
*
)
tree
))
<
0
)
if
((
error
=
git_
tree_dup
(
&
tree
,
tree
))
<
0
)
return
error
;
ti
=
git__calloc
(
1
,
sizeof
(
tree_iterator
));
...
...
@@ -1849,7 +1849,7 @@ int git_iterator_for_workdir_ext(
return
error
;
}
if
(
tree
&&
(
error
=
git_
object_dup
((
git_object
**
)
&
wi
->
tree
,
(
git_object
*
)
tree
))
<
0
)
if
(
tree
&&
(
error
=
git_
tree_dup
(
&
wi
->
tree
,
tree
))
<
0
)
return
error
;
wi
->
index
=
index
;
...
...
src/object_api.c
View file @
f0224772
...
...
@@ -15,7 +15,7 @@
#include "tag.h"
/**
*
Blob
*
Commit
*/
int
git_commit_lookup
(
git_commit
**
out
,
git_repository
*
repo
,
const
git_oid
*
id
)
{
...
...
@@ -42,6 +42,10 @@ git_repository *git_commit_owner(const git_commit *obj)
return
git_object_owner
((
const
git_object
*
)
obj
);
}
int
git_commit_dup
(
git_commit
**
out
,
git_commit
*
obj
)
{
return
git_object_dup
((
git_object
**
)
out
,
(
git_object
*
)
obj
);
}
/**
* Tree
...
...
@@ -71,6 +75,10 @@ git_repository *git_tree_owner(const git_tree *obj)
return
git_object_owner
((
const
git_object
*
)
obj
);
}
int
git_tree_dup
(
git_tree
**
out
,
git_tree
*
obj
)
{
return
git_object_dup
((
git_object
**
)
out
,
(
git_object
*
)
obj
);
}
/**
* Tag
...
...
@@ -100,6 +108,11 @@ git_repository *git_tag_owner(const git_tag *obj)
return
git_object_owner
((
const
git_object
*
)
obj
);
}
int
git_tag_dup
(
git_tag
**
out
,
git_tag
*
obj
)
{
return
git_object_dup
((
git_object
**
)
out
,
(
git_object
*
)
obj
);
}
/**
* Blob
*/
...
...
@@ -127,3 +140,8 @@ git_repository *git_blob_owner(const git_blob *obj)
{
return
git_object_owner
((
const
git_object
*
)
obj
);
}
int
git_blob_dup
(
git_blob
**
out
,
git_blob
*
obj
)
{
return
git_object_dup
((
git_object
**
)
out
,
(
git_object
*
)
obj
);
}
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