summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorEdward Thomson <ethomson@github.com>2016-02-17 18:04:19 +0000
committerEdward Thomson <ethomson@github.com>2016-03-23 17:08:37 -0400
commitf0224772ee4300d55e11ab6f84cb3dd64b35ecfd (patch)
tree5f4857f12f0268973f8d4a758043413f4b164f0d /include/git2
parent684b35c41b9166645e2edb9bc708aa7ddf9c1f24 (diff)
downloadlibgit2-f0224772ee4300d55e11ab6f84cb3dd64b35ecfd.tar.gz
git_object_dup: introduce typesafe versions
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/blob.h9
-rw-r--r--include/git2/commit.h9
-rw-r--r--include/git2/tag.h9
-rw-r--r--include/git2/tree.h9
4 files changed, 36 insertions, 0 deletions
diff --git a/include/git2/blob.h b/include/git2/blob.h
index f451593cd..6377fc2a2 100644
--- a/include/git2/blob.h
+++ b/include/git2/blob.h
@@ -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
diff --git a/include/git2/commit.h b/include/git2/commit.h
index f63a90685..4cc637466 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -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
diff --git a/include/git2/tag.h b/include/git2/tag.h
index c822cee7c..cb95fb5ef 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -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
diff --git a/include/git2/tree.h b/include/git2/tree.h
index 550a44857..8a2be2102 100644
--- a/include/git2/tree.h
+++ b/include/git2/tree.h
@@ -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