summaryrefslogtreecommitdiffstats
path: root/include/git2/commit.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:03:04 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-21 05:03:04 +0000
commitb88736462df2c86a83f01dcc260b5463205819d2 (patch)
treeb1a9a5a5392a52ec4e5f60fb4b45083cf7fd65b0 /include/git2/commit.h
parentAdding upstream version 1.7.2+ds. (diff)
downloadlibgit2-b88736462df2c86a83f01dcc260b5463205819d2.tar.xz
libgit2-b88736462df2c86a83f01dcc260b5463205819d2.zip
Adding upstream version 1.8.1+ds.upstream/1.8.1+dsupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--include/git2/commit.h67
1 files changed, 64 insertions, 3 deletions
diff --git a/include/git2/commit.h b/include/git2/commit.h
index 67170cb..ef38c66 100644
--- a/include/git2/commit.h
+++ b/include/git2/commit.h
@@ -366,7 +366,7 @@ GIT_EXTERN(int) git_commit_create(
const char *message,
const git_tree *tree,
size_t parent_count,
- const git_commit *parents[]);
+ git_commit * const parents[]);
/**
* Create new commit in the repository using a variable argument list.
@@ -394,6 +394,49 @@ GIT_EXTERN(int) git_commit_create_v(
size_t parent_count,
...);
+typedef struct {
+ unsigned int version;
+
+ /**
+ * Flags for creating the commit.
+ *
+ * If `allow_empty_commit` is specified, a commit with no changes
+ * from the prior commit (and "empty" commit) is allowed. Otherwise,
+ * commit creation will be stopped.
+ */
+ unsigned int allow_empty_commit : 1;
+
+ /** The commit author, or NULL for the default. */
+ const git_signature *author;
+
+ /** The committer, or NULL for the default. */
+ const git_signature *committer;
+
+ /** Encoding for the commit message; leave NULL for default. */
+ const char *message_encoding;
+} git_commit_create_options;
+
+#define GIT_COMMIT_CREATE_OPTIONS_VERSION 1
+#define GIT_COMMIT_CREATE_OPTIONS_INIT { GIT_COMMIT_CREATE_OPTIONS_VERSION }
+
+/**
+ * Commits the staged changes in the repository; this is a near analog to
+ * `git commit -m message`.
+ *
+ * By default, empty commits are not allowed.
+ *
+ * @param id pointer to store the new commit's object id
+ * @param repo repository to commit changes in
+ * @param message the commit message
+ * @param opts options for creating the commit
+ * @return 0 on success, GIT_EUNCHANGED if there were no changes to commit, or an error code
+ */
+GIT_EXTERN(int) git_commit_create_from_stage(
+ git_oid *id,
+ git_repository *repo,
+ const char *message,
+ const git_commit_create_options *opts);
+
/**
* Amend an existing commit by replacing only non-NULL values.
*
@@ -469,7 +512,7 @@ GIT_EXTERN(int) git_commit_create_buffer(
const char *message,
const git_tree *tree,
size_t parent_count,
- const git_commit *parents[]);
+ git_commit * const parents[]);
/**
* Create a commit object from the given buffer and signature
@@ -538,9 +581,27 @@ typedef int (*git_commit_create_cb)(
const char *message,
const git_tree *tree,
size_t parent_count,
- const git_commit *parents[],
+ git_commit * const parents[],
void *payload);
+/** An array of commits returned from the library */
+typedef struct git_commitarray {
+ git_commit *const *commits;
+ size_t count;
+} git_commitarray;
+
+/**
+ * Free the commits contained in a commit array. This method should
+ * be called on `git_commitarray` objects that were provided by the
+ * library. Not doing so will result in a memory leak.
+ *
+ * This does not free the `git_commitarray` itself, since the library
+ * will never allocate that object directly itself.
+ *
+ * @param array The git_commitarray that contains commits to free
+ */
+GIT_EXTERN(void) git_commitarray_dispose(git_commitarray *array);
+
/** @} */
GIT_END_DECL
#endif