*/
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
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
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
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
assert(ancestor && commit);
- if (git_object_dup((git_object **) ¤t, (git_object *) commit) < 0)
+ if (git_commit_dup(¤t, (git_commit *)commit) < 0)
return -1;
if (n == 0) {
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);
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));
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;
#include "tag.h"
/**
- * Blob
+ * Commit
*/
int git_commit_lookup(git_commit **out, git_repository *repo, const git_oid *id)
{
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
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
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
*/
{
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);
+}