summaryrefslogtreecommitdiff
path: root/include/git2
diff options
context:
space:
mode:
authorVicent Marti <tanoku@gmail.com>2011-06-28 19:15:48 +0200
committerVicent Marti <tanoku@gmail.com>2011-06-28 19:36:27 +0200
commitd5afc0390c3ef919fcde23300d7aefdaeafa5daa (patch)
tree0b661ef8536266c5bf5de645025c8072bc35dc85 /include/git2
parent0b10c9ea6ef5d85d862edd044d96561c4fd16e9b (diff)
downloadlibgit2-d5afc0390c3ef919fcde23300d7aefdaeafa5daa.tar.gz
Remove redundant methods from the API
A bunch of redundant methods have been removed from the external API. - All the reference/tag creation methods with `_f` are gone. The force flag is now passed as an argument to the normal create methods. - All the different commit creation methods are gone; commit creation now always requires a `git_commit` pointer for parents and a `git_tree` pointer for tree, to ensure that corrupted commits cannot be generated. - All the different tag creation methods are gone; tag creation now always requires a `git_object` pointer to ensure that tags are not created to inexisting objects.
Diffstat (limited to 'include/git2')
-rw-r--r--include/git2/commit.h73
-rw-r--r--include/git2/oid.h13
-rw-r--r--include/git2/refs.h50
-rw-r--r--include/git2/tag.h104
4 files changed, 47 insertions, 193 deletions
diff --git a/include/git2/commit.h b/include/git2/commit.h
index 356b875cd..84adef596 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -193,7 +193,8 @@ GIT_EXTERN(int) git_commit_parent(git_commit **parent, git_commit *commit, unsig
GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned int n);
/**
- * Create a new commit in the repository
+ * Create a new commit in the repository using `git_object`
+ * instances as parameters.
*
* @param oid Pointer where to store the OID of the
* newly created commit
@@ -214,16 +215,16 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i
*
* @param message Full message for this commit
*
- * @param tree_oid Object ID of the tree for this commit. Note that
- * no validation is performed on this OID. Use the _o variants of
- * this method to assure a proper tree is passed to the commit.
+ * @param tree An instance of a `git_tree` object that will
+ * be used as the tree for the commit. This tree object must
+ * also be owned by the given `repo`.
*
* @param parent_count Number of parents for this commit
*
- * @param parent_oids[] Array of pointers to parent OIDs for this commit.
- * Note that no validation is performed on these OIDs. Use the _o
- * variants of this method to assure that are parents for the commit
- * are proper objects.
+ * @param parents[] Array of `parent_count` pointers to `git_commit`
+ * objects that will be used as the parents for this commit. This
+ * array may be NULL if `parent_count` is 0 (root commit). All the
+ * given commits must be owned by the `repo`.
*
* @return 0 on success; error code otherwise
* The created commit will be written to the Object Database and
@@ -236,38 +237,13 @@ GIT_EXTERN(int) git_commit_create(
const git_signature *author,
const git_signature *committer,
const char *message,
- const git_oid *tree_oid,
- int parent_count,
- const git_oid *parent_oids[]);
-
-/**
- * Create a new commit in the repository using `git_object`
- * instances as parameters.
- *
- * The `tree_oid` and `parent_oids` paremeters now take a instance
- * of `git_tree` and `git_commit`, respectively.
- *
- * All other parameters remain the same
- *
- * @see git_commit_create
- */
-GIT_EXTERN(int) git_commit_create_o(
- git_oid *oid,
- git_repository *repo,
- const char *update_ref,
- const git_signature *author,
- const git_signature *committer,
- const char *message,
const git_tree *tree,
int parent_count,
const git_commit *parents[]);
/**
- * Create a new commit in the repository using `git_object`
- * instances and a variable argument list.
- *
- * The `tree_oid` paremeter now takes a instance
- * of `const git_tree *`.
+ * Create a new commit in the repository using a variable
+ * argument list.
*
* The parents for the commit are specified as a variable
* list of pointers to `const git_commit *`. Note that this
@@ -278,31 +254,6 @@ GIT_EXTERN(int) git_commit_create_o(
*
* @see git_commit_create
*/
-GIT_EXTERN(int) git_commit_create_ov(
- git_oid *oid,
- git_repository *repo,
- const char *update_ref,
- const git_signature *author,
- const git_signature *committer,
- const char *message,
- const git_tree *tree,
- int parent_count,
- ...);
-
-
-/**
- * Create a new commit in the repository using
- * a variable argument list.
- *
- * The parents for the commit are specified as a variable
- * list of pointers to `const git_oid *`. Note that this
- * is a convenience method which may not be safe to export
- * for certain languages or compilers
- *
- * All other parameters remain the same
- *
- * @see git_commit_create
- */
GIT_EXTERN(int) git_commit_create_v(
git_oid *oid,
git_repository *repo,
@@ -310,7 +261,7 @@ GIT_EXTERN(int) git_commit_create_v(
const git_signature *author,
const git_signature *committer,
const char *message,
- const git_oid *tree_oid,
+ const git_tree *tree,
int parent_count,
...);
diff --git a/include/git2/oid.h b/include/git2/oid.h
index 06bbfcc55..46d0dce0d 100644
--- a/include/git2/oid.h
+++ b/include/git2/oid.h
@@ -65,6 +65,19 @@ typedef struct {
GIT_EXTERN(int) git_oid_fromstr(git_oid *out, const char *str);
/**
+ * Parse N characters of a hex formatted object id into a git_oid
+ *
+ * If N is odd, N-1 characters will be parsed instead.
+ * The remaining space in the git_oid will be set to zero.
+ *
+ * @param out oid structure the result is written into.
+ * @param str input hex string of at least size `length`
+ * @param length length of the input string
+ * @return GIT_SUCCESS if valid; GIT_ENOTOID on failure.
+ */
+GIT_EXTERN(int) git_oid_fromstrn(git_oid *out, const char *str, size_t length);
+
+/**
* Copy an already raw oid into a git_oid structure.
*
* @param out oid structure the result is written into.
diff --git a/include/git2/refs.h b/include/git2/refs.h
index 2c3aac7b0..384e8e2f8 100644
--- a/include/git2/refs.h
+++ b/include/git2/refs.h
@@ -60,34 +60,17 @@ GIT_EXTERN(int) git_reference_lookup(git_reference **reference_out, git_reposito
* This reference is owned by the repository and shall not
* be free'd by the user.
*
- * @param ref_out Pointer to the newly created reference
- * @param repo Repository where that reference will live
- * @param name The name of the reference
- * @param target The target of the reference
- * @return 0 on success; error code otherwise
- */
-GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repository *repo, const char *name, const char *target);
-
-/**
- * Create a new symbolic reference, overwriting an existing one with
- * the same name, if it exists.
- *
- * If the new reference isn't a symbolic one, any pointers to the old
- * reference become invalid.
- *
- * The reference will be created in the repository and written
- * to the disk.
- *
- * This reference is owned by the repository and shall not
- * be free'd by the user.
+ * If `force` is true and there already exists a reference
+ * with the same name, it will be overwritten.
*
* @param ref_out Pointer to the newly created reference
* @param repo Repository where that reference will live
* @param name The name of the reference
* @param target The target of the reference
+ * @param force Overwrite existing references
* @return 0 on success; error code otherwise
*/
-GIT_EXTERN(int) git_reference_create_symbolic_f(git_reference **ref_out, git_repository *repo, const char *name, const char *target);
+GIT_EXTERN(int) git_reference_create_symbolic(git_reference **ref_out, git_repository *repo, const char *name, const char *target, int force);
/**
* Create a new object id reference.
@@ -98,34 +81,17 @@ GIT_EXTERN(int) git_reference_create_symbolic_f(git_reference **ref_out, git_rep
* This reference is owned by the repository and shall not
* be free'd by the user.
*
- * @param ref_out Pointer to the newly created reference
- * @param repo Repository where that reference will live
- * @param name The name of the reference
- * @param id The object id pointed to by the reference.
- * @return 0 on success; error code otherwise
- */
-GIT_EXTERN(int) git_reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id);
-
-/**
- * Create a new object id reference, overwriting an existing one with
- * the same name, if it exists.
- *
- * If the new reference isn't an object id one, any pointers to the
- * old reference become invalid.
- *
- * The reference will be created in the repository and written
- * to the disk.
- *
- * This reference is owned by the repository and shall not
- * be free'd by the user.
+ * If `force` is true and there already exists a reference
+ * with the same name, it will be overwritten.
*
* @param ref_out Pointer to the newly created reference
* @param repo Repository where that reference will live
* @param name The name of the reference
* @param id The object id pointed to by the reference.
+ * @param force Overwrite existing references
* @return 0 on success; error code otherwise
*/
-GIT_EXTERN(int) git_reference_create_oid_f(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id);
+GIT_EXTERN(int) git_reference_create_oid(git_reference **ref_out, git_repository *repo, const char *name, const git_oid *id, int force);
/**
* Get the OID pointed to by a reference.
diff --git a/include/git2/tag.h b/include/git2/tag.h
index b92f79d22..11eac90e3 100644
--- a/include/git2/tag.h
+++ b/include/git2/tag.h
@@ -151,6 +151,10 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
/**
* Create a new tag in the repository from an OID
*
+ * A new reference will also be created pointing to
+ * this tag object. If `force` is true and a reference
+ * already exists with the given name, it'll be replaced.
+ *
* @param oid Pointer where to store the OID of the
* newly created tag. If the tag already exists, this parameter
* will be the oid of the existed tag, and the function will
@@ -162,18 +166,16 @@ GIT_EXTERN(const char *) git_tag_message(git_tag *tag);
* for consistency. It should also not conflict with an
* already existing tag name
*
- * @param target OID to which this tag points; note that no
- * validation is done on this OID. Use the _o version of this
- * method to assure a proper object is being tagged
- *
- * @param target_type Type of the tagged OID; note that no
- * validation is performed here either
+ * @param target Object to which this tag points. This object
+ * must belong to the given `repo`.
*
* @param tagger Signature of the tagger for this tag, and
* of the tagging time
*
* @param message Full message for this tag
*
+ * @param force Overwritte existing references
+ *
* @return 0 on success; error code otherwise.
* A tag object is written to the ODB, and a proper reference
* is written in the /refs/tags folder, pointing to it
@@ -182,103 +184,25 @@ GIT_EXTERN(int) git_tag_create(
git_oid *oid,
git_repository *repo,
const char *tag_name,
- const git_oid *target,
- git_otype target_type,
- const git_signature *tagger,
- const char *message);
-
-
-/**
- * Create a new tag in the repository from an existing
- * `git_object` instance
- *
- * This method replaces the `target` and `target_type`
- * paremeters of `git_tag_create` by a single instance
- * of a `const git_object *`, which is assured to be
- * a proper object in the ODB and hence will create
- * a valid tag
- *
- * @see git_tag_create
- */
-GIT_EXTERN(int) git_tag_create_o(
- git_oid *oid,
- git_repository *repo,
- const char *tag_name,
const git_object *target,
const git_signature *tagger,
- const char *message);
+ const char *message,
+ int force);
/**
* Create a new tag in the repository from a buffer
*
* @param oid Pointer where to store the OID of the newly created tag
- *
* @param repo Repository where to store the tag
- *
* @param buffer Raw tag data
+ * @param force Overwrite existing tags
+ * @return 0 on sucess; error code otherwise
*/
GIT_EXTERN(int) git_tag_create_frombuffer(
git_oid *oid,
git_repository *repo,
- const char *buffer);
-
-/**
- * Create a new tag in the repository from an OID
- * and overwrite an already existing tag reference, if any.
- *
- * @param oid Pointer where to store the OID of the
- * newly created tag
- *
- * @param repo Repository where to store the tag
- *
- * @param tag_name Name for the tag; this name is validated
- * for consistency.
- *
- * @param target OID to which this tag points; note that no
- * validation is done on this OID. Use the _fo version of this
- * method to assure a proper object is being tagged
- *
- * @param target_type Type of the tagged OID; note that no
- * validation is performed here either
- *
- * @param tagger Signature of the tagger for this tag, and
- * of the tagging time
- *
- * @param message Full message for this tag
- *
- * @return 0 on success; error code otherwise.
- * A tag object is written to the ODB, and a proper reference
- * is written in the /refs/tags folder, pointing to it
- */
-GIT_EXTERN(int) git_tag_create_f(
- git_oid *oid,
- git_repository *repo,
- const char *tag_name,
- const git_oid *target,
- git_otype target_type,
- const git_signature *tagger,
- const char *message);
-
-/**
- * Create a new tag in the repository from an existing
- * `git_object` instance and overwrite an already existing
- * tag reference, if any.
- *
- * This method replaces the `target` and `target_type`
- * paremeters of `git_tag_create_f` by a single instance
- * of a `const git_object *`, which is assured to be
- * a proper object in the ODB and hence will create
- * a valid tag
- *
- * @see git_tag_create_f
- */
-GIT_EXTERN(int) git_tag_create_fo(
- git_oid *oid,
- git_repository *repo,
- const char *tag_name,
- const git_object *target,
- const git_signature *tagger,
- const char *message);
+ const char *buffer,
+ int force);
/**
* Delete an existing tag reference.