libgit2

git_commit_create_ext

Version:

Create a new commit object and write it to the object database.

Note that the message will not be cleaned up automatically. You may wish to use the git_message_prettify API to clean it up.

This API provides the most control for generating commit objects; this is useful if (for example) you have a tree object already. If you have staged changes, and just want to emulate git commit on the command line, then git_commit_create_from_stage may be a simpler option.

Signature

int git_commit_create_ext(git_oid *id_out, git_repository *repo, const git_signature *author, const git_signature *committer, const char *message, const git_tree *tree, size_t parent_count, git_commit *const *parents, const git_commit_create_ext_options *opts);

Parameters

In
id_out

pointer to store the new commit's object id

In
repo

repository to store the commit in

In
author

The name of the author and time of authorship

In
committer

The name of the committer and time of commit

const char *
In
message

Full message for this commit

In
tree

The git_tree that will be used as the tree for this commit

size_t
In
parent_count

Number of parents for this commit

In
parents

Array pointers to git_commit objects that will be used as parents for this commit.

In
opts

Additional options for creating this commit, or NULL for defaults

Returns

int

0 on success or an error code

Versions