mirror of
https://github.com/libgit2/libgit2.git
synced 2026-01-25 02:56:17 +00:00
commit: fix const declaration
commit functions should take an array of const pointers, not a const array.
This commit is contained in:
@@ -263,7 +263,7 @@ static int create_merge_commit(git_repository *repo, git_index *index, struct me
|
||||
sign, sign,
|
||||
NULL, msg,
|
||||
tree,
|
||||
opts->annotated_count + 1, (const git_commit **)parents);
|
||||
opts->annotated_count + 1, parents);
|
||||
check_lg2(err, "failed to create commit", NULL);
|
||||
|
||||
/* We're done merging, cleanup the repository state */
|
||||
|
||||
@@ -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.
|
||||
@@ -469,7 +469,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,7 +538,7 @@ 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 */
|
||||
|
||||
@@ -281,7 +281,7 @@ int git_commit_create_from_ids(
|
||||
|
||||
typedef struct {
|
||||
size_t total;
|
||||
const git_commit **parents;
|
||||
git_commit * const *parents;
|
||||
git_repository *repo;
|
||||
} commit_parent_data;
|
||||
|
||||
@@ -307,7 +307,7 @@ int git_commit_create(
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[])
|
||||
git_commit * const parents[])
|
||||
{
|
||||
commit_parent_data data = { parent_count, parents, repo };
|
||||
|
||||
@@ -945,7 +945,7 @@ int git_commit_create_buffer(
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[])
|
||||
git_commit * const parents[])
|
||||
{
|
||||
GIT_BUF_WRAP_PRIVATE(out, git_commit__create_buffer, repo,
|
||||
author, committer, message_encoding, message,
|
||||
@@ -961,7 +961,7 @@ int git_commit__create_buffer(
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[])
|
||||
git_commit * const parents[])
|
||||
{
|
||||
int error;
|
||||
commit_parent_data data = { parent_count, parents, repo };
|
||||
|
||||
@@ -64,7 +64,7 @@ int git_commit__create_buffer(
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[]);
|
||||
git_commit * const parents[]);
|
||||
|
||||
int git_commit__parse(
|
||||
void *commit,
|
||||
|
||||
@@ -303,7 +303,7 @@ static int note_write(
|
||||
|
||||
error = git_commit_create(&oid, repo, notes_ref, author, committer,
|
||||
NULL, GIT_NOTES_DEFAULT_MSG_ADD,
|
||||
tree, *parents == NULL ? 0 : 1, (const git_commit **) parents);
|
||||
tree, *parents == NULL ? 0 : 1, parents);
|
||||
|
||||
if (notes_commit_out)
|
||||
git_oid_cpy(notes_commit_out, &oid);
|
||||
@@ -394,7 +394,7 @@ static int note_remove(
|
||||
NULL, GIT_NOTES_DEFAULT_MSG_RM,
|
||||
tree_after_removal,
|
||||
*parents == NULL ? 0 : 1,
|
||||
(const git_commit **) parents);
|
||||
parents);
|
||||
|
||||
if (error < 0)
|
||||
goto cleanup;
|
||||
|
||||
@@ -952,7 +952,7 @@ static int create_signed(
|
||||
const char *message,
|
||||
git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit **parents)
|
||||
git_commit * const *parents)
|
||||
{
|
||||
git_str commit_content = GIT_STR_INIT;
|
||||
git_buf commit_signature = { NULL, 0, 0 },
|
||||
@@ -1040,8 +1040,7 @@ static int rebase_commit__create(
|
||||
if (rebase->options.commit_create_cb) {
|
||||
error = rebase->options.commit_create_cb(&commit_id,
|
||||
author, committer, message_encoding, message,
|
||||
tree, 1, (const git_commit **)&parent_commit,
|
||||
rebase->options.payload);
|
||||
tree, 1, &parent_commit, rebase->options.payload);
|
||||
|
||||
git_error_set_after_callback_function(error,
|
||||
"commit_create_cb");
|
||||
@@ -1050,14 +1049,14 @@ static int rebase_commit__create(
|
||||
else if (rebase->options.signing_cb) {
|
||||
error = create_signed(&commit_id, rebase, author,
|
||||
committer, message_encoding, message, tree,
|
||||
1, (const git_commit **)&parent_commit);
|
||||
1, &parent_commit);
|
||||
}
|
||||
#endif
|
||||
|
||||
if (error == GIT_PASSTHROUGH)
|
||||
error = git_commit_create(&commit_id, rebase->repo, NULL,
|
||||
author, committer, message_encoding, message,
|
||||
tree, 1, (const git_commit **)&parent_commit);
|
||||
tree, 1, &parent_commit);
|
||||
|
||||
if (error)
|
||||
goto done;
|
||||
|
||||
@@ -124,7 +124,7 @@ static int commit_index(
|
||||
git_index *index,
|
||||
const git_signature *stasher,
|
||||
const char *message,
|
||||
const git_commit *parent)
|
||||
git_commit *parent)
|
||||
{
|
||||
git_tree *i_tree = NULL;
|
||||
git_oid i_commit_oid;
|
||||
@@ -423,7 +423,7 @@ static int build_stash_commit_from_tree(
|
||||
git_commit *u_commit,
|
||||
const git_tree *tree)
|
||||
{
|
||||
const git_commit *parents[] = { NULL, NULL, NULL };
|
||||
git_commit *parents[] = { NULL, NULL, NULL };
|
||||
|
||||
parents[0] = b_commit;
|
||||
parents[1] = i_commit;
|
||||
|
||||
@@ -1235,7 +1235,7 @@ void test_checkout_tree__case_changing_rename(void)
|
||||
|
||||
cl_git_pass(git_signature_new(&signature, "Renamer", "rename@contoso.com", time(NULL), 0));
|
||||
|
||||
cl_git_pass(git_commit_create(&commit_id, g_repo, "refs/heads/dir", signature, signature, NULL, "case-changing rename", tree, 1, (const git_commit **)&dir_commit));
|
||||
cl_git_pass(git_commit_create(&commit_id, g_repo, "refs/heads/dir", signature, signature, NULL, "case-changing rename", tree, 1, &dir_commit));
|
||||
|
||||
cl_assert(git_fs_path_isfile("testrepo/readme"));
|
||||
if (case_sensitive)
|
||||
|
||||
@@ -77,7 +77,7 @@ void test_cherrypick_workdir__automerge(void)
|
||||
cl_git_pass(git_index_write_tree(&cherrypicked_tree_oid, repo_index));
|
||||
cl_git_pass(git_tree_lookup(&cherrypicked_tree, repo, &cherrypicked_tree_oid));
|
||||
cl_git_pass(git_commit_create(&cherrypicked_oid, repo, "HEAD", signature, signature, NULL,
|
||||
"Cherry picked!", cherrypicked_tree, 1, (const git_commit **)&head));
|
||||
"Cherry picked!", cherrypicked_tree, 1, &head));
|
||||
|
||||
cl_assert(merge_test_index(repo_index, merge_index_entries + i * 3, 3));
|
||||
|
||||
|
||||
@@ -36,11 +36,11 @@ void test_commit_commit__create_unexisting_update_ref(void)
|
||||
|
||||
cl_git_fail(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar"));
|
||||
cl_git_pass(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s,
|
||||
NULL, "some msg", tree, 1, (const git_commit **) &commit));
|
||||
NULL, "some msg", tree, 1, &commit));
|
||||
|
||||
/* fail because the parent isn't the tip of the branch anymore */
|
||||
cl_git_fail(git_commit_create(&oid, _repo, "refs/heads/foo/bar", s, s,
|
||||
NULL, "some msg", tree, 1, (const git_commit **) &commit));
|
||||
NULL, "some msg", tree, 1, &commit));
|
||||
|
||||
cl_git_pass(git_reference_lookup(&ref, _repo, "refs/heads/foo/bar"));
|
||||
cl_assert_equal_oid(&oid, git_reference_target(ref));
|
||||
|
||||
@@ -118,7 +118,7 @@ void test_commit_write__into_buf(void)
|
||||
cl_git_pass(git_commit_lookup(&parent, g_repo, &parent_id));
|
||||
|
||||
cl_git_pass(git_commit_create_buffer(&commit, g_repo, author, committer,
|
||||
NULL, root_commit_message, tree, 1, (const git_commit **) &parent));
|
||||
NULL, root_commit_message, tree, 1, &parent));
|
||||
|
||||
cl_assert_equal_s(commit.ptr,
|
||||
"tree 1810dff58d8a660512d4832e740f692884338ccd\n\
|
||||
|
||||
@@ -424,7 +424,7 @@ void test_diff_rename__test_small_files(void)
|
||||
cl_git_pass(git_index_write_tree(&oid, index));
|
||||
cl_git_pass(git_tree_lookup(&commit_tree, g_repo, &oid));
|
||||
cl_git_pass(git_signature_new(&signature, "Rename", "rename@example.com", 1404157834, 0));
|
||||
cl_git_pass(git_commit_create(&oid, g_repo, "HEAD", signature, signature, NULL, "Test commit", commit_tree, 1, (const git_commit**)&head_commit));
|
||||
cl_git_pass(git_commit_create(&oid, g_repo, "HEAD", signature, signature, NULL, "Test commit", commit_tree, 1, &head_commit));
|
||||
|
||||
cl_git_mkfile("renames/copy.txt", "Hello World!\n");
|
||||
cl_git_rmfile("renames/small.txt");
|
||||
|
||||
@@ -125,7 +125,7 @@ void test_odb_freshen__tree_during_commit(void)
|
||||
|
||||
cl_git_pass(git_commit_create(&commit_id, repo, NULL,
|
||||
signature, signature, NULL, "New commit pointing to old tree",
|
||||
tree, 1, (const git_commit **)&parent));
|
||||
tree, 1, &parent));
|
||||
|
||||
/* make sure we freshen the tree the commit points to */
|
||||
cl_must_pass(p_lstat("testrepo.git/objects/" LOOSE_TREE_FN, &after));
|
||||
|
||||
@@ -26,7 +26,7 @@ static int create_cb_passthrough(
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[],
|
||||
git_commit * const parents[],
|
||||
void *payload)
|
||||
{
|
||||
GIT_UNUSED(out);
|
||||
@@ -94,7 +94,7 @@ static int create_cb_signed_gpg(
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[],
|
||||
git_commit * const parents[],
|
||||
void *payload)
|
||||
{
|
||||
git_buf commit_content = GIT_BUF_INIT;
|
||||
@@ -202,7 +202,7 @@ static int create_cb_error(
|
||||
const char *message,
|
||||
const git_tree *tree,
|
||||
size_t parent_count,
|
||||
const git_commit *parents[],
|
||||
git_commit * const parents[],
|
||||
void *payload)
|
||||
{
|
||||
GIT_UNUSED(out);
|
||||
|
||||
@@ -233,7 +233,7 @@ void test_refs_reflog_messages__show_merge_for_merge_commits(void)
|
||||
cl_git_pass(git_commit_create(&merge_commit_oid,
|
||||
g_repo, "HEAD", s, s, NULL,
|
||||
"Merge commit", tree,
|
||||
2, (const struct git_commit **) parent_commits));
|
||||
2, parent_commits));
|
||||
|
||||
cl_reflog_check_entry(g_repo, GIT_HEAD_FILE, 0,
|
||||
NULL,
|
||||
|
||||
@@ -188,7 +188,7 @@ void test_revert_workdir__again(void)
|
||||
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
|
||||
|
||||
cl_git_pass(git_signature_new(&signature, "Reverter", "reverter@example.org", time(NULL), 0));
|
||||
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&orig_head));
|
||||
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &orig_head));
|
||||
|
||||
cl_git_pass(git_revert(repo, orig_head, NULL));
|
||||
cl_assert(merge_test_index(repo_index, merge_index_entries, 4));
|
||||
@@ -238,7 +238,7 @@ void test_revert_workdir__again_after_automerge(void)
|
||||
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
|
||||
|
||||
cl_git_pass(git_signature_new(&signature, "Reverter", "reverter@example.org", time(NULL), 0));
|
||||
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&head));
|
||||
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &head));
|
||||
|
||||
cl_git_pass(git_revert(repo, commit, NULL));
|
||||
cl_assert(merge_test_index(repo_index, second_revert_entries, 6));
|
||||
@@ -287,7 +287,7 @@ void test_revert_workdir__again_after_edit(void)
|
||||
cl_git_pass(git_tree_lookup(&reverted_tree, repo, &reverted_tree_oid));
|
||||
|
||||
cl_git_pass(git_signature_new(&signature, "Reverter", "reverter@example.org", time(NULL), 0));
|
||||
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, (const git_commit **)&orig_head));
|
||||
cl_git_pass(git_commit_create(&reverted_commit_oid, repo, "HEAD", signature, signature, NULL, "Reverted!", reverted_tree, 1, &orig_head));
|
||||
|
||||
cl_git_pass(git_revert(repo, commit, NULL));
|
||||
cl_assert(merge_test_index(repo_index, merge_index_entries, 4));
|
||||
|
||||
@@ -550,8 +550,7 @@ void test_revwalk_basic__big_timestamp(void)
|
||||
cl_git_pass(git_signature_new(&sig, "Joe", "joe@example.com", INT64_C(2399662595), 0));
|
||||
cl_git_pass(git_commit_tree(&tree, tip));
|
||||
|
||||
cl_git_pass(git_commit_create(&id, _repo, "HEAD", sig, sig, NULL, "some message", tree, 1,
|
||||
(const git_commit **)&tip));
|
||||
cl_git_pass(git_commit_create(&id, _repo, "HEAD", sig, sig, NULL, "some message", tree, 1, &tip));
|
||||
|
||||
cl_git_pass(git_revwalk_push_head(_walk));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user