mirror of
https://github.com/libgit2/libgit2.git
synced 2026-06-22 06:26:26 +00:00
commit: rearrange _fromstate and _on_head variants
We now have `_fromstate` and `_fromstate_on_head`, the latter of which updates the current branch to point to the new commit.
This commit is contained in:
@@ -353,20 +353,20 @@ GIT_EXTERN(int) git_commit_create_on(
|
||||
const git_commit *parents[]);
|
||||
|
||||
/**
|
||||
* Create a commit and update the current branch
|
||||
* Create a commit from the current state and update the current branch
|
||||
*
|
||||
* @see git_commit_create
|
||||
* Like `git_commit_create_fromstate`; additionally the current branch will be
|
||||
* updated.
|
||||
*
|
||||
* @see git_commit_create_fromstate
|
||||
*/
|
||||
GIT_EXTERN(int) git_commit_create_on_head(
|
||||
GIT_EXTERN(int) git_commit_create_fromstate_on_head(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[]);
|
||||
const char *message);
|
||||
|
||||
/**
|
||||
* Create new commit in the repository using a variable argument list.
|
||||
@@ -478,9 +478,8 @@ GIT_EXTERN(int) git_commit_create_buffer(
|
||||
* variant takes the current state of the repository instead of
|
||||
* arguments.
|
||||
*
|
||||
* The current branch will be updated. The tree will be created from
|
||||
* the repository's index. The parents will be taken from HEAD and
|
||||
* MERGE_HEAD, if applicable.
|
||||
* The tree will be created from the repository's index. The parents will be
|
||||
* taken from HEAD and MERGE_HEAD, if applicable.
|
||||
*
|
||||
* @see git_commit_create
|
||||
*/
|
||||
|
||||
43
src/commit.c
43
src/commit.c
@@ -313,22 +313,6 @@ int git_commit_create_on(
|
||||
commit_parent_from_array, &data, false);
|
||||
}
|
||||
|
||||
int git_commit_create_on_head(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[])
|
||||
{
|
||||
return git_commit_create_on(id, repo, GIT_HEAD_FILE,
|
||||
author, committer, message_encoding, message,
|
||||
tree, parent_count, parents);
|
||||
}
|
||||
|
||||
int git_commit_create(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
@@ -443,9 +427,10 @@ int gather_commit_ids(const git_oid *id, void *payload)
|
||||
return insert_commit(data->commits, data->repo, id);
|
||||
}
|
||||
|
||||
int git_commit_create_fromstate(
|
||||
static int commit_fromstate(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
const char *update_ref,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
@@ -486,7 +471,7 @@ int git_commit_create_fromstate(
|
||||
if ((error = git_tree_lookup(&tree, repo, &tree_id)) < 0)
|
||||
goto cleanup;
|
||||
|
||||
error = git_commit_create_on(id, repo, GIT_HEAD_FILE,
|
||||
error = git_commit_create_on(id, repo, update_ref,
|
||||
author, committer, message_encoding, message,
|
||||
tree, commits.length, (const git_commit **) commits.contents);
|
||||
|
||||
@@ -499,6 +484,28 @@ cleanup:
|
||||
return 0;
|
||||
}
|
||||
|
||||
int git_commit_create_fromstate(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message)
|
||||
{
|
||||
return commit_fromstate(id, repo, NULL, author, committer, message_encoding, message);
|
||||
}
|
||||
|
||||
int git_commit_create_fromstate_on_head(
|
||||
git_oid *id,
|
||||
git_repository *repo,
|
||||
const git_signature *author,
|
||||
const git_signature *committer,
|
||||
const char *message_encoding,
|
||||
const char *message)
|
||||
{
|
||||
return commit_fromstate(id, repo, GIT_HEAD_FILE, author, committer, message_encoding, message);
|
||||
}
|
||||
|
||||
int git_commit__parse(void *_commit, git_odb_object *odb_obj)
|
||||
{
|
||||
git_commit *commit = _commit;
|
||||
|
||||
Reference in New Issue
Block a user